Shulou(Shulou.com)06/01 Report--
Editor to share with you how html5 to achieve simple custom elements to play focus map animation, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
HTML Code:
SmartSite Ver 2.2 intelligent website management system adopts the technology of complete separation of front and background, and adds template technology through tag (supporting label loop nesting, judging tag, custom tag, file loop nesting, etc.). The whole site generates pure static pages.
Learn More
Enterprise website management system single page, single page index, news, product display, download, friendship link, online mall, online payment, distribution, payment management, advertising and other modules.
Learn More
< count; i++) { html += "slide"; } html += ""; $el.append(html); } function sweepOut($el, windowWidth) { var dfr = $.Deferred(), pos = $el.position(), width = $el.width(), delta, final, options = $el.data("tlrkAnimOptions"); windowWidth = windowWidth || $(window).width(); // check if the windowWidth is passed, if not - get it delta = windowWidth - pos.left; final = -(delta); setTimeout(function(){ $el.animate({left: final, opacity: "toggle"}, options.speed, options.easing, function(){ dfr.resolve(); }); }, options.delay); return dfr.promise(); } function sweepIn($el, windowWidth, frameLeft) { var dfr = $.Deferred(), options = $el.data("tlrkAnimOptions"), positionData = $el.data("tlrkOriginalPos"), final = positionData.position.left, rightEdge; windowWidth = windowWidth || $(window).width(); // check if the windowWidth is passed, if not - get it $el.css({opacity: 0, display: "block"}); // move it outside the right edge of the screen $el.css("left", function(current){ return current + windowWidth - frameLeft; }); setTimeout(function(){ $el.animate({left: final, opacity: 1}, options.speed, options.easing, function(){ dfr.resolve(); }); }, options.delay); return dfr.promise(); } // two pass function that first iterates all the elements and gets their position/width/height // and then sets their position to absolute function absolutize($elements) { // todo - move it to separate function and do it just once // gather the original position/dimension data for all elements $elements.each(function(){ var $t = $(this); if ($t.data("tlrkOriginalPos")) return $t.data("tlrkOriginalPos", { position: $t.position(), width: $t.width(), height: $t.height(), css_pos: $t.css("position"), css_left: $t.css("left"), css_top: $t.css("top"), css_width: $t.css("width") || "auto", css_height: $t.css("height") || "auto" }); }); // set the absolute position $elements.each(function(){ var $t = $(this), opos = $t.data("tlrkOriginalPos"); $t.css({ position: "absolute", left: opos.position.left, top: opos.position.top, width: opos.width, height: opos.height }); }); } function restoreFrameElements($elements) { $elements.each(function(){ var $t = $(this), opos = $t.data("tlrkOriginalPos"); if (!opos) return $t.css({ position: opos.css_pos, left: opos.css_left, top: opos.css_top, width: opos.css_width, height: opos.css_height }); }); } var TlrkSlider = function( elem, options ){ this.elem = elem; this.$elem = $(elem); this.options = options; }; // the plugin prototype TlrkSlider.prototype = { defaults: { defaultElementOptions: { speed: 1200, easing: "easeInOutBack", // interval before the element starts moving when the fadeIn/Out functions are called // it's a good idea to give different delays for the different elements // if all have the same delay they'll start moving all together delay: 100 }, // dispose elements are these that are not included in the elements object // but affect the document flow and will be fadedIn/Out disposeDelay: 100, // delay for the dispose elements disposeSpeed: 1000, // how quickly they'll fadeOut/In delayBetweenTransition: 1000, // time between starting fadeOut and fadeIn delayAnimation: 7000, // time between auto changing the current frame loop: true, // if true when clicking next on the last frame the slider jumps to the first one autoStart: true, // start the automatic looping through the frames on init framesSelector: "section", // selector for the frames inside the slider elements: { "p": {delay: 100, speed: 1000, easing: "easeInOutBack"} }, navigation: true, // the dots navigation on the bottom navigationClass: "slider-nav", // callbacks // another way to "catch" these events is with // $(-slider-element-).bind("animationStart") animationStart: null, animationEnd: null }, init: function() { var c, e, element, $element, that = this, $firstFrame; c = this.config = $.extend({}, this.defaults, this.options); this.elem.style.position = "relative"; // make the wrapping element relative // basics this.$frames = this.$elem.find(c.framesSelector); this.framesCount = this.$frames.length; this.currentFrame = 0; this.queue = []; this._$elementsByFrame = {}; this._$disposeElementsByFrame = {}; for (i = 0; i < this.framesCount; i++) { this._$elementsByFrame[i] = this._getFrameElements(i); // cache the $elements by frame this._$disposeElementsByFrame[i] = this._getDisposeFrameElements(i); // cache the rest of the tree for each frame } if (c.navigation) { generateNavigation(this.$elem, this.framesCount, c); this.$navigation = this.$elem.find("."+c.navigationClass); } // bindings this.$elem.find(".slider-nav").delegate("a", "click", function(e){ var frame = this.getAttribute("href").split("#")[1]; that.go.call(that, frame); return false; }); this.$elem // internal bindings for the callbacks .bind("animationStart", function(){ if ($.isFunction(c.animationStart)) {c.animationStart.apply(that, arguments);} }) .bind("animationEnd", function(){ if ($.isFunction(c.animationEnd)) {c.animationEnd.apply(that, arguments);} }) ; // start animation? if (c.autoStart) { this.start(); } else { this.running = false; } return this; }, start: function(instant) { var that = this; if (this.timer) { // we'll clear the current timer window.clearTimeout(this.timer); } this.running = true; if (instant) { that.nextFrame(); } else { this.timer = window.setTimeout(function(){ that.nextFrame.call(that) }, that.config.delayAnimation); } }, stop: function() { if (!this.running) return; // we are not running this.running = false; window.clearTimeout(this.timer); }, // main function for changing frames selectFrame: function(frame, dfr) { var c = this.config, // shorthand for the config that = this, dfr = dfr || $.Deferred(), dFadeIn = $.Deferred(), dFadeOut = $.Deferred(); if (isNaN(frame) || frame < 0 || frame >
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.