seamscroll
Version:
js seamless scroll
1 lines • 4.84 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.seamscroll=e():t.seamscroll=e()}("undefined"!=typeof self?self:this,function(){return function(t){function e(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t["default"]}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1);n.d(e,"init",function(){return i.a})},function(t,e,n){"use strict";var i=n(2),o=function(t){return new i.a(t)};e.a=o},function(t,e,n){"use strict";var i=n(5),o=n(6);n(3)();var r=n(4),s={step:1,hoverStop:!0,direction:1,singleHeight:0,singleWidth:0,waitTime:1e3},a=function(t){this.options=r({},s,t);var e=this.options.dom;if(!e)throw new Error("you must set a dom");if(e.style.position="relative",e.style.overflow="hidden",this.reqFrame=null,this.singleWaitTime=null,this._top=0,this._left=0,this.isHover=!1,e.innerHTML+=e.innerHTML,this.options.direction>1){var n=e.children,i=n[0],o=n.length;this._width=(i.offsetWidth+this._getInt(i,"margin-left")+this._getInt(i,"margin-right"))*o,e.style.width=this._width+"px"}this._move(),this._bindEvent()};a.prototype={_getInt:function(t,e){return parseInt(Object(o.a)(t,e))},_cancle:function(){cancelAnimationFrame(this.reqFrame||"")},_bindEvent:function(){if(this.options.hoverStop){var t=this,e=this.options.dom;Object(i.a)(e,"mouseenter",function(){t.isHover=!0,t.singleWaitTime&&clearTimeout(t.singleWaitTime),t._cancle()}),Object(i.a)(e,"mouseleave",function(){t.isHover=!1,t._move()})}},_move:function(){if(!this.isHover){this._cancle();var t=this,e=this.options.dom;this.reqFrame=requestAnimationFrame(function(){var n=e.offsetHeight/2,i=t.options.direction;1===i?(Math.abs(t._top)>=n&&(t._top=0),t._top-=t.options.step,e.style.top=t._top+"px"):0===i?(t._top>=0&&(t._top=-1*n),t._top+=t.options.step,e.style.top=t._top+"px"):2===i?(Math.abs(t._left)>=t._width/2&&(t._left=0),t._left-=t.options.step,e.style.left=t._left+"px"):3===i&&(t._left>=0&&(t._left=t._width/2*-1),t._left+=t.options.step,e.style.left=t._left+"px"),t._judgeSingle()})}},_judgeSingle:function(){var t=this,e=this.options.singleHeight,n=this.options.singleWidth;this.singleWaitTime&&clearTimeout(this.singleWaitTime),e?Math.abs(this._top)%e==0?this.singleWaitTime=setTimeout(function(){t._move()},this.options.waitTime):this._move():n&&Math.abs(this._left)%n==0?this.singleWaitTime=setTimeout(function(){t._move()},this.options.waitTime):this._move()}},e.a=a},function(t,e){var n=function(){window.cancelAnimationFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t)}}(),window.requestAnimationFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}()};t.exports=n},function(t,e){function n(){Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)});var t=void 0,e=void 0,i=void 0,r=void 0,s=void 0,a=void 0,u=1,c=arguments[0]||{},f=!1,l=arguments.length;if("boolean"==typeof c&&(f=c,c=arguments[1]||{},u++),"object"!==(void 0===c?"undefined":o(c))&&"function"!=typeof c&&(c={}),u===l)return c;for(;u<l;u++)if(null!=(e=arguments[u]))for(t in e)i=c[t],r=e[t],s=Array.isArray(r),f&&r&&("object"===(void 0===r?"undefined":o(r))||s)?(s?(s=!1,a=i&&Array.isArray(i)?i:[]):a=i&&"object"===(void 0===i?"undefined":o(i))?i:{},c[t]=n(f,a,r)):r!==undefined&&(c[t]=r);return c}var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o="function"==typeof Symbol&&"symbol"===i(Symbol.iterator)?function(t){return void 0===t?"undefined":i(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":void 0===t?"undefined":i(t)};t.exports=n},function(t,e,n){"use strict";var i=function(t,e,n){t.addEventListener?t.addEventListener(e,n,!1):t.attachEvent?t.attachEvent("on"+e,n):t["on"+e]=n};e.a=i},function(t,e,n){"use strict";var i=function(t,e){return(t.currentStyle?t.currentStyle:window.getComputedStyle(t,null))[e]};e.a=i}])});