国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

目次
HTML代碼
CSS代碼:
JavaScript代碼:
ホームページ ウェブフロントエンド H5 チュートリアル HTML5 カスタム要素の再生フォーカス チャート アニメーションのサンプル コードの詳細(xì)な紹介

HTML5 カスタム要素の再生フォーカス チャート アニメーションのサンプル コードの詳細(xì)な紹介

Mar 06, 2017 pm 03:34 PM

這是一款基于HTML5的焦點圖動畫,它和其他焦點圖不同的地方在于,它播放的不僅僅是圖片,而是可以自定義控制的網(wǎng)頁元素。它不僅在圖片間切換有過渡動畫效果,而且在切換時圖片中的元素也將出現(xiàn)動畫效果,比如圖中的文字移動、打散、重新組合等。這款HTML5動畫圖片播放器算得上是高端大氣上檔次。

HTML代碼

<p class="parallax-bg" id="slider-wrap">
	<p class="slider parallax-bg" id="slider">
           <p class="slider-sections sandbox"> 
		<section class="first">
                     <img alt="Kendo UI" src="images/home-banner-1.png"/>
                     <p class="text">
                          <h2>SmartSite Ver 2.2<br />智能網(wǎng)站管理系統(tǒng) </h2>
                    <p class="copy">采用前后臺完全分離技術(shù),通過標(biāo)簽(支持標(biāo)簽循環(huán)嵌套、判斷標(biāo)簽、自定義標(biāo)簽、文件循環(huán)嵌套等)加模板技術(shù).全站生成純靜態(tài)頁。</p>
                          <p class="button"><a href="#" onclick="_gaq.push([&#39;_trackPageview&#39;, &#39;#&#39;]);">Download</a> 
                          <a class="dimmed" onclick="_gaq.push([&#39;_trackPageview&#39;, &#39;#&#39;]);" href="#">Learn More</a></p>
                     </p>
                </section>
		<section>
                     <img src="images/dataviz-home-image-q2.png" alt="Kendo UI" />
                     <p class="text" style="padding-top: 10px;">
                          <h2>企業(yè)網(wǎng)站管理系統(tǒng)</h2>
                          <p class="copy">單頁面、單頁面索引、新聞、產(chǎn)品展示、下載、友情鏈接、網(wǎng)上商城,在線支付、配送、支付方式管理、廣告等模塊。</p>
                          <p class="button"><a href="#" onclick="_gaq.push([&#39;_trackPageview&#39;, &#39;#&#39;]);">Download</a> 
                          <a class="dimmed" onclick="_gaq.push([&#39;_trackPageview&#39;, &#39;#&#39;]);" href="#">Learn More</a></p>
                     </p>
                </section>
		<section>
                     <img src="images/home_banner_web-q2.png" alt="Kendo UI" />
                     <p class="text">
                          <h2>智能移動網(wǎng)站管理系統(tǒng)</h2>
                          <p class="copy">基于jquery.Mobile、HTML5技術(shù)框架,前后臺完全分離,采用標(biāo)簽加模板技術(shù),全站生成純靜態(tài)頁。</p>
                          <p class="button"><a href="#" onclick="_gaq.push([&#39;_trackPageview&#39;, &#39;#&#39;]);">Download</a> 
                          <a class="dimmed" onclick="_gaq.push([&#39;_trackPageview&#39;, &#39;#&#39;]);" href="#">Learn More</a></p>
                     </p>
                </section>
           </p>
      </p>
      <a class="slider-prev" href="javascript: void(0)">?</a> <a class="slider-next" href="javascript: void(0)">?</a>
</p>

CSS代碼:

這里列出的是這個焦點圖相關(guān)的核心CSS代碼。

.slider section {display: none;}
.slider section.first {display: block;}

.slider-sections, .slider-sections section {width: 861px; height: 335px;}

.slider-sections {margin: 0 auto; position: relative;}
.slider-sections section {position: absolute; top: 0; left: 0px; }

.header-content h2 
{
	font:400 32px/1.2 "microsoft yahei", Tahoma, arial, sans-serif;
	color: #fff;
	margin: 0 0 26px;
}
.header-content p 
{
    margin: 0 0 30px;
}

.header-content .centered-content
{
	padding-top: 30px;
	padding-bottom: 10px;
}

.button {
	float: left;
	width: auto !important;
	list-style: none;
}
	.button a,
	.button button,
	.button input { /* Standard black button */
	  font-size: 15px;
	  /*font-family: &#39;lucida sans&#39;,arial,helvetica,sans-serif;*/
	  line-height: 18px;
		color: #fff !important;

	  text-decoration: none;

	  padding: 5px 14px 6px 13px;
		display: block;
		width: auto;
		position: relative;
		z-index: 2;

	    border: none;
        -moz-border-radius: 3px;
		border-radius: 3px;
		cursor: pointer;

		background: #313131; /* Old browsers */
		background: -moz-linear-gradient(top, #313131 0%, #222222 100%); /* FF3.6+ */
		background: -webkit-linear-gradient(top, #313131 0%,#222222 100%); /* Chrome10+,Safari5.1+ */
		background: -o-linear-gradient(top, #313131 0%,#222222 100%); /* Opera11.10+ */
		background: -ms-linear-gradient(top, #313131 0%,#222222 100%); /* IE10+ */
		background: linear-gradient(top, #313131 0%,#222222 100%); /* W3C */

		-webkit-transition: all 0.3s ease;
		-moz-transition: all 0.3s ease;
		-o-transition: all 0.3s ease;
		transition: all  0.3s ease;
	}

	.button a:hover,
	.button input:hover,
	.button button:hover,
	.button a:focus,
	.button input:focus,
	.button button:focus
	{
	  background: #464646; /* Old browsers */
		background: -moz-linear-gradient(top, #464646 0%, #393939 100%); /* FF3.6+ */
		background: -webkit-linear-gradient(top, #464646 0%,#393939 100%); /* Chrome10+,Safari5.1+ */
		background: -o-linear-gradient(top, #464646 0%,#393939 100%); /* Opera11.10+ */
		background: -ms-linear-gradient(top, #464646 0%,#393939 100%); /* IE10+ */
		background: linear-gradient(top, #464646 0%,#393939 100%); /* W3C */
    }

	header .header-content .button a,
	#content .button a:hover
	{
	    text-decoration: none;
    }

.header-content .beta-ribbons {
    position: absolute; 
    height: 120px;
    width: 85px;
    text-indent: -200px;
    overflow: hidden;
    background: url(../images/kendo-ribbons.png) no-repeat 0 0;
}

.header-content .beta-ribbons.ribbon-1 {
    background-position: -170px 0;
    top: -3px;
    right: -145px;
}

.header-content p.copy .beta-ribbons.ribbon-1 {
    top: -135px;
    left: 900px;
}

.header-content .beta-ribbons.ribbon-4 {
    background-position: -255px 0;
    left: -62px;
    top: -30px;
    z-index: 10;
		text-indent: -2000px;
}

JavaScript代碼:

下面是這個焦點圖插件的代碼。

/**
* @author Alexander Farkas
* v. 1.22
*/
(function ($)
{
    if (!document.defaultView || !document.defaultView.getComputedStyle)
    { // IE6-IE8
        var oldCurCSS = $.curCSS;
        $.curCSS = function (elem, name, force)
        {
            if (name === &#39;background-position&#39;)
            {
                name = &#39;backgroundPosition&#39;;
            }
            if (name !== &#39;backgroundPosition&#39; || !elem.currentStyle || elem.currentStyle[name])
            {
                return oldCurCSS.apply(this, arguments);
            }
            var style = elem.style;
            if (!force && style && style[name])
            {
                return style[name];
            }
            return oldCurCSS(elem, &#39;backgroundPositionX&#39;, force) + &#39; &#39; + oldCurCSS(elem, &#39;backgroundPositionY&#39;, force);
        };
    }

    var oldAnim = $.fn.animate;
    $.fn.animate = function (prop)
    {
        if (&#39;background-position&#39; in prop)
        {
            prop.backgroundPosition = prop[&#39;background-position&#39;];
            delete prop[&#39;background-position&#39;];
        }
        if (&#39;backgroundPosition&#39; in prop)
        {
            prop.backgroundPosition = &#39;(&#39; + prop.backgroundPosition;
        }
        return oldAnim.apply(this, arguments);
    };

    function toArray(strg)
    {
        strg = strg.replace(/left|top/g, &#39;0px&#39;);
        strg = strg.replace(/right|bottom/g, &#39;100%&#39;);
        strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g, "$1px$2");
        var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
        return [parseFloat(res[1], 10), res[2], parseFloat(res[3], 10), res[3]];
    }

    $.fx.step.backgroundPosition = function (fx)
    {
        if (!fx.bgPosReady)
        {
            var start = $.curCSS(fx.elem, &#39;backgroundPosition&#39;);
            if (!start)
            {//FF2 no inline-style fallback
                start = &#39;0px 0px&#39;;
            }

            start = toArray(start);
            fx.start = [start[0], start[2]];
            var end = toArray(fx.end);
            fx.end = [end[0], end[2]];

            fx.unit = [end[1], end[3]];
            fx.bgPosReady = true;
        }
        //return;
        var nowPosX = [];
        nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
        nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
        fx.elem.style.backgroundPosition = nowPosX[0] + &#39; &#39; + nowPosX[1];

    };
})(jQuery);

/*
tlrkSlider

  example usage:

    $("#slider").tlrkSlider({
      autoStart: false,
      elements: {
        "img": {delay: 10},
        "h2": {delay: 500},
        ".copy": {delay: 800},
        ".button": {delay: 1000}
      }
    });

  to go to a specific frame:
    $("#slider").tlrkSlider("go", position);
    "position" can have one of the following values:
    "next", "prev", "first", "last", "+1", "-1" or a numeric value

  to start/stop the automatic loop:
    $("#slider").tlrkSlider("start");
    $("#slider").tlrkSlider("stop");

  to change the delay between automatic transitions:
    $("#slider").tlrkSlider("option", "delayAnimation", 1000);

  to change any option:
    $("#slider").tlrkSlider("option", option_name, option_value);

  Changing the "elements" object is not tested.

  Changing the following options: "navigation", "navigationClass", "framesSelector", "autoStart" won&#39;t have any effect for now.
  They are used only during the initialization.

  $("#slider").data("tlrkSlider") will return the plugin instance and the methods/properties can be accessed from there.

  The plugin contructor defaults are accessable through TlrkSlider.defaults

  The function that actually sweep the elements in/out can be overriden from
    TlrkSlider.prototype._animationIn and TlrkSlider.prototype._animationOut

    See sweepIn/sweepOut 

 */

;(function( $, window, document, undefined ){

  // utility function that generates the "dots" navigation
  function generateNavigation($el, count, config) {
    var i, html = "",
        width = count * 24;

    html += "<ol class=&#39;" + config.navigationClass + "&#39; style=&#39;margin-left: -" + width/2 + "px; width: " + width + "px&#39;>";
    for (i = 0; i < count; i++) {
      html += "<li><a " + (i === 0 ? "class=&#39;selected&#39;" : "" ) + " href=&#39;#" + (i) + "&#39;>slide</a></li>";
    }
    html += "</ol>";

    $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&#39;s a good idea to give different delays for the different elements
        // if all have the same delay they&#39;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&#39;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&#39;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 > this.framesCount || frame === this.currentFrame) {
        dfr.reject();
        return dfr.promise();
      }

      // clear the animation loop interval if the animation is running
      if (this.running && this.timer) { 
        window.clearTimeout(this.timer);
      }

      // check if we are currenly running an animation.
      if (this.animated && this.queue.length > 0) {
        // wait for the last item in the queue to finish
        this.queue[this.queue.length-1].done(function(){
          that.selectFrame(frame, dfr); // and call again the selectFrame
        })
        return dfr.promise();
      }

      this.animated = true;
      this.$elem.trigger("animationStart", [this, frame]);

      this.queue.push(dfr);

      // fade the frames
      dFadeOut = this._fadeOutFrame(this.currentFrame);

      // hide the fadetout frame
      dFadeOut.done(function(){
        that.$frames.eq(that.currentFrame).hide();
      });

      window.setTimeout(function(){ // then wait delayBetweenTransition and fadeIn the new frame
        dFadeIn = that._fadeInFrame.call(that, frame).done(function(){
          // when both the fadeIn and fadeOut are done we&#39;ll resolve the selectFrame promise
          $.when(dFadeOut, dFadeIn).done(function(){
            that.animated = false;
            that.queue.shift();
            that.$elem.trigger("animationEnd", [that]);
            that.currentFrame = frame;
            dfr.resolve();
          });
        });
      }, c.delayBetweenTransition);

      // navigation html change
      if (this.config.navigation) {
        this.$navigation.find(".selected").removeClass("selected").end()
          .find("a").eq(frame).addClass("selected");
      }

      dfr.done(function(){ // we&#39;ll resume the loop animation after the transitions are done
        if (that.running) {
          that.start();
        }
      });

      return dfr.promise();
    },

    _fadeFrame: function(frame, callback, direction) {
      var dfr = $.Deferred(),
          $frame = this.$frames.eq(frame),
          $elements = this._$elementsByFrame[frame],
          windowWidth = $(window).width(), // cache it before the animations, so we don&#39;t have to check it for each element 
          i, len,
          that = this,
          elementAnimations = [],
          $disposeElements = this._$disposeElementsByFrame[frame],
          $affectedElements,
          frameLeft = $frame.offset().left;

      direction = direction || "out";

      if (!$.isFunction(callback)) return; // do nothing if there&#39;s no callback passed

      $affectedElements = $elements.add($disposeElements);

      // position absolute the animation and dispose elements
      absolutize($affectedElements);

      // toggle the dispose elements
      if ($disposeElements.length > 0) {
        window.setTimeout(function(){
          $disposeElements[direction === "out" ? "fadeOut" : "fadeIn"](that.config.disposeSpeed);
        }, this.config.disposeDelay);
      }

      // invoke the callback for each element
      // the callback must return a promise
      $elements.each(function(){
        elementAnimations.push( callback.call(that, $(this), windowWidth, frameLeft) );
      });

      // wait for all the elements to finish their animation
      $.when.apply(this, elementAnimations).done(function(){
        //restoreFrameElements($affectedElements); // and restore the elements&#39; position
        dfr.resolve(); // resolve the fade function
      });

      return dfr.promise();
    },

    _fadeOutFrame: function(frame) {
      var dfr = $.Deferred(),
          $frame = this.$frames.eq(frame),
          $disposeElements = this._$disposeElementsByFrame[frame];

      this._fadeFrame(frame, this._animationOut, "out").done(function(){
        dfr.resolve();
      })

      return dfr.promise();
    },

    _fadeInFrame: function(frame) {
      var dfr = $.Deferred(),
          $frame = this.$frames.eq(frame),
          $elements = this._$elementsByFrame[frame];

      this._restoreFrame(frame);

      $frame.show();

      this._fadeFrame(frame, this._animationIn, "in").done(function(){
        dfr.resolve();
      });

      return dfr.promise();
    },

    _restoreFrame: function(frame){
      if (!frame) return
      restoreFrameElements( this._$elementsByFrame[frame].add(this._$disposeElementsByFrame[frame]) );
    },

    nextFrame: function() {
      var frame = this.currentFrame+1,
          dfr = $.Deferred();

      if (frame > this.framesCount-1) {
        if (this.config.loop) {
          frame = 0;
        } else {
          dfr.reject();
        }
      };

      this.selectFrame(frame).done(function(){
        dfr.resolve();
      });

      return dfr.promise();
    },

    prevFrame: function() {
      var frame = this.currentFrame-1,
          dfr = $.Deferred();

      if (frame < 0) {
        if (this.config.loop) {
          frame = this.framesCount-1;
        } else {
          dfr.reject();
          return dfr.promise();
        }
      }

      this.selectFrame(frame).done(function(){
        dfr.resolve();
      });

      return dfr.promise();
    },

    go: function(str) { // shorthand
      switch (str) {
        case "next":
        case "+1":
          this.nextFrame();
          break;

        case "prev":
        case "-1":
          this.prevFrame();
          break;

        case "first":
          this.selectFrame(0);
          break;

        case "last":
          this.selectFrame(this.framesCount-1);
          break;

        default:
          if (isNaN(str)) return;
          this.selectFrame(Number(str));
      }
    },

    // returns jquery collection of animation elements
    _getFrameElements: function(frame) { 
      var $frame = this.$frames.eq(frame),
          elements = this.config.elements,
          e, elementOptions,
          $found, $frameElements = $([]);

      for (e in elements) {
        elementOptions = elements[e];
        $found = $frame.find(e);
        $found.addClass("t-frame-element").data("tlrkAnimOptions", $.extend({}, this.defaults.defaultElementOptions, elementOptions ));
        $frameElements = $frameElements.add($found);
      }

      return $frameElements;
    },

    // returns jquery collection of elements that have to be faded out
    // i.e. elements on the same level as the animation elements
    // that doesn&#39;t contain other animation elements
    _getDisposeFrameElements: function(frame) {
      var $disposeElements = $([]),
          $frame = this.$frames.eq(frame),
          $elements = this._$elementsByFrame[frame];

      $elements.each(function(){
        var $t = $(this),
            $siblings = $t.siblings().not(".t-frame-element");

        $siblings.each(function(){
          var $t = $(this);
          // check if the node is not already marked and doesn&#39;t contains other frame elements
          if (!$t.hasClass("t-frame-dispose") && $t.find(".t-frame-element").length === 0) {
            $t.addClass("t-frame-dispose");
            $disposeElements = $disposeElements.add($t);
          }
        });

      });
      return $disposeElements;
    },

    // expose the internal animationIn/Out functions that are called for each element in the frame
    // two arguments are passed - the $element which have to be animated and the window width
    _animationIn: sweepIn,
    _animationOut: sweepOut

  }

  TlrkSlider.defaults = TlrkSlider.prototype.defaults;

  $.fn.tlrkSlider = function(options) {
    var otherArgs = Array.prototype.slice.call(arguments, 1);

    return this.each(function() {
      var $el = $(this),
          pluginData = $el.data("tlrkSlider");

      if (!pluginData) { // check if the slider is already attached
        pluginData = new TlrkSlider(this, options).init();
        $el.data("tlrkSlider", pluginData);
        return;
      }

      //change the options or call a method
      if (typeof options === "string") {

        // setting / getting option(s)
        if (options === "option") {

          if (typeof otherArgs[0] === "string" && typeof otherArgs[1] !== "undefined") { // set an option value
            pluginData.config[otherArgs[0]] = otherArgs[1]; 
          }

          if (typeof otherArgs[0] === "object") { // extend the config with new options
            pluginData.config = $.extend(pluginData.config, otherArgs[0]);
          }

        } else { // call a method?
          try {
            pluginData[options].apply(pluginData, otherArgs);
          } catch(ex) {
            throw "Error calling a plugin method (" + ex + ")";
          }
        }
      }
    });
  };

  window.TlrkSlider = TlrkSlider;

})( jQuery, window , document );

下面是頁面調(diào)用的JS代碼:

$(document).ready(function(){
  var $backgrounds = $(".header-content").find(".parallax-bg"),
      LAYER_OFFSET = 30,
      PRLX_SPEED = 1500,
      $slider;

  $slider = $("#slider").tlrkSlider({
    autoStart: true,
    animationStart: function(ev, slider, step){
      var max_steps = this.framesCount; 
      $backgrounds.each(function(idx, el){
        var pos = (step * (100 / max_steps)) + (LAYER_OFFSET * idx);
        $(this).animate({"backgroundPosition": pos + "% 0"}, PRLX_SPEED);
      });
    },
    elements: {
      "img": {delay: 10},
      "h2": {delay: 500},
      ".copy": {delay: 800},
      ".button": {delay: 1000}
    }
  });

  $(".header-content")
    .hover(
      function(){$(this).find(".slider-prev, .slider-next").show();},
      function(){$(this).find(".slider-prev, .slider-next").hide();}
    )
    .find(".slider-prev").click(function(){$slider.tlrkSlider("go", "prev"); return false; }).end()
    .find(".slider-next").click(function(){$slider.tlrkSlider("go", "next"); return false; });

});

以上就是HTML5自定義元素播放焦點圖動畫示例代碼詳細(xì)介紹的內(nèi)容,更多相關(guān)內(nèi)容請關(guān)注PHP中文網(wǎng)(www.miracleart.cn)!



このウェブサイトの聲明
この記事の內(nèi)容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰屬します。このサイトは、それに相當(dāng)する法的責(zé)任を負(fù)いません。盜作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡(luò)ください。

ホットAIツール

Undress AI Tool

Undress AI Tool

脫衣畫像を無料で

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード寫真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

寫真から衣服を削除するオンライン AI ツール。

Clothoff.io

Clothoff.io

AI衣類リムーバー

Video Face Swap

Video Face Swap

完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

ホットツール

メモ帳++7.3.1

メモ帳++7.3.1

使いやすく無料のコードエディター

SublimeText3 中國語版

SublimeText3 中國語版

中國語版、とても使いやすい

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統(tǒng)合開発環(huán)境

ドリームウィーバー CS6

ドリームウィーバー CS6

ビジュアル Web 開発ツール

SublimeText3 Mac版

SublimeText3 Mac版

神レベルのコード編集ソフト(SublimeText3)

HTML5サーバーセントイベントでの再接続とエラーの処理。 HTML5サーバーセントイベントでの再接続とエラーの処理。 Jul 03, 2025 am 02:28 AM

HTML5SSEを使用する場合、再接続とエラーに対処する方法には次のものが含まれます。1。デフォルトの再接続メカニズムを理解します。 EventSourceは、デフォルトで接続が中斷されてから3秒後に再試行します。再試行フィールドを介して間隔をカスタマイズできます。 2.接続障害または解析エラーに対処するためにエラーイベントを聞いて、自動再接続に依存しているネットワークの問題、サーバーエラーが手動で再接続を遅らせる、認(rèn)証障害の更新トークンなど、対応するロジックを?qū)g行し、実行するロジックを?qū)g行します。 3.接続の手動での閉鎖と再構(gòu)築、再試行時間の最大數(shù)を設(shè)定するなど、再接続ロジックを積極的に制御し、ナビゲーターを組み合わせてネットワークステータスを判斷して再試行戦略を最適化します。これらのメジャーは、アプリケーションの安定性とユーザーエクスペリエンスを改善できます。

CSSとJavaScriptをHTML5構(gòu)造と効果的に統(tǒng)合します。 CSSとJavaScriptをHTML5構(gòu)造と効果的に統(tǒng)合します。 Jul 12, 2025 am 03:01 AM

HTML5、CSS、およびJavaScriptは、セマンティックタグ、妥當(dāng)な読み込み順序、デカップリング設(shè)計と効率的に組み合わせる必要があります。 1. SEOやバリアのないアクセスを助長する構(gòu)造の明確性と保守性の向上など、HTML5セマンティックタグを使用します。 2。CSSを配置し、外部ファイルを使用し、モジュールごとに分割して、インラインスタイルと遅延荷重問題を回避する必要があります。 3. JavaScriptは、前に導(dǎo)入され、Deferまたは非同期を使用して非同期にロードすることをお勧めします。 4. 3つの間の強い依存性を減らし、データ - *屬性とクラス名制御ステータスを介して動作を促進(jìn)し、統(tǒng)一された命名仕様を介してコラボレーション効率を改善します。これらの方法は、ページのパフォーマンスを効果的に最適化し、チームと協(xié)力することができます。

HTML5サーバーセントイベント(SSE)でリアルタイムデータを受信します。 HTML5サーバーセントイベント(SSE)でリアルタイムデータを受信します。 Jul 02, 2025 pm 04:46 PM

Server-Sentevents(SSE)は、HTML5が提供する軽量ソリューションで、リアルタイムの更新をブラウザにプッシュします。株式市場、通知、その他のシナリオに適した長いHTTP接続を介した一方向通信を?qū)g現(xiàn)します。 EventSourceインスタンスを作成し、次の場合にメッセージをリッスンします。ConsteventSource= newEventSource( '/stream'); eventsource.onmessage = function(event){console.log( 'receece message:'、event.data);};サーバーは、コンテンツタイプをテキスト/イベントに設(shè)定する必要があります

最新のページの正しいHTML5 Doctypeを宣言します。 最新のページの正しいHTML5 Doctypeを宣言します。 Jul 03, 2025 am 02:35 AM

Doctypeは、ページを解析するために使用するHTML標(biāo)準(zhǔn)をブラウザに伝えるステートメントです。最新のWebページは、HTMLファイルの先頭に記述するだけです。その機能は、ブラウザが奇妙なモードではなく標(biāo)準(zhǔn)モードでページをレンダリングし、その前にスペースやコメントがない最初の行に配置する必要があることを確認(rèn)することです。それを書く正しい方法は1つだけであり、古いバージョンやその他のバリアントを使用することはお勧めしません。 charset、viewportなどのその他は、部分的に配置する必要があります。

HTML5セマンティックマークアップとマイクロダタでSEOを改善します。 HTML5セマンティックマークアップとマイクロダタでSEOを改善します。 Jul 03, 2025 am 01:16 AM

HTML5セマンティックタグとマイクロダタを使用すると、SEOが改善できます。これは、検索エンジンがページ構(gòu)造とコンテンツの意味をよりよく理解するのに役立つためです。 1. ,,,、などのHTML5セマンティックタグを使用し、ページブロックの関數(shù)を明確にします。これにより、検索エンジンがより正確なページモデルを確立するのに役立ちます。 2。検索エンジンが情報タイプを識別し、リッチメディアの概要を表示するためにそれらを使用できるように、記事著者、リリース日、製品価格など、特定のコンテンツをマークするためにマイクロダタ構(gòu)造データを追加します。 3.タグの正しい使用に注意して、混亂を避け、タグの重複を避け、構(gòu)造化されたデータの有効性をテストし、定期的に更新してschema.orgの変更に適応し、他のSEO手段と組み合わせて長期的に最適化します。

html5 `` vs ``要素の説明。 html5 `` vs ``要素の説明。 Jul 12, 2025 am 03:09 AM

レイアウトに適したブロックレベルの要素です。これは、テキストコンテンツのラッピングに適したインライン要素です。 1.ラインのみを占有し、幅、高さ、マージンを設(shè)定できます。これは、構(gòu)造レイアウトでよく使用されます。 2.ラインブレークなし、サイズはコンテンツによって決定され、ローカルテキストスタイルまたは動的操作に適しています。 3.選択するときは、コンテンツに獨立したスペースが必要かどうかに基づいて判斷する必要があります。 4.ネストすることはできず、レイアウトには適していません。 5。構(gòu)造的な明確さとアクセシビリティを改善するために、セマンティックラベルの使用が優(yōu)先されます。

HTML5 Geolocation APIでユーザーの現(xiàn)在の場所を取得します。 HTML5 Geolocation APIでユーザーの現(xiàn)在の場所を取得します。 Jul 02, 2025 pm 05:03 PM

HTML5Geolocation APIを使用してユーザーの位置を取得する場合、最初にユーザー認(rèn)証を取得し、適切なタイミングで目的を要求および説明する必要があります?;镜膜史椒à稀avigator.geolocation.getCurrentPosition()です。これには、成功したコールバック、間違ったコールバック、構(gòu)成パラメーターが含まれています。障害の一般的な理由には、許可の拒否、サポートされていないブラウザ、ネットワークの問題など、代替ソリューション、明確なプロンプトが提供される必要があります。特定の提案は次のとおりです。1。ボタンのクリックなど、ユーザー操作がトリガーされたときのアクセス許可を要求します。 2。ポジショニング効果を最適化するために、enableHighAccuracy、Timeout、Maximageage、その他のパラメーターを使用します。 3.エラー処理は、異なるエラーを區(qū)別する必要があります

HTML5メディアソース拡張機能(MSE)の理解 HTML5メディアソース拡張機能(MSE)の理解 Jul 08, 2025 am 02:31 AM

MSE(MediaSourceExtensions)はW3C標(biāo)準(zhǔn)の一部であり、JavaScriptがメディアストリームを動的に構(gòu)築できるため、高度なビデオ再生機能を可能にします。 MediaSourceを介してメディアソースを管理し、SourceBufferのデータを保存し、タイマーを介したバッファリング時間範(fàn)囲を表し、ブラウザがビデオクリップを動的にロードおよびデコードできるようにします。 MSEを使用するプロセスには以下が含まれます。 sthingそれを要素にバインドします。 source SourceBufferを追加して、特定の形式でデータを受信します。 fetch()を介してセグメント化されたデータを取得し、バッファーに追加します。一般的な注意事項には以下が含まれます。 ②タイムスタンプペア

See all articles