How I Develop Carousel Module

1,374 views

Published on

Published in: Technology
  • Be the first to comment

How I Develop Carousel Module

  1. 1. LIFE IS HARD
  2. 2. 555…
  3. 3. KISSY().use("carousel", function(S) { var handle = new S.Carousel('sample', { direction: 'h', autoStart: false, speed: 500, scrollWidth: 400, onBeforeScroll: function() { // ... } }); // handle.next(); // handle.prev(); // handle.jumpTo(); });
  4. 4. KISSY().use("slideview", function(S) { var slideView = new S.SlideView("sample", { autoPlay: false, effectType: "scrollx", activeTriggerCls: "current" }); slideView.subscribe("onSwitch", function(index) { // ... }); });
  5. 5. KISSY.augment(ScrollView, Y.EventProvider);
  6. 6. var getRealOffset = function(elem) { var elem = Dom.get(elem), leftOffset = elem.offsetLeft, topOffset = elem.offsetTop, parent = elem.offsetParent; // fix IE offsetLeft bug, see // http://www.gtalbot.org/BrowserBugsSection/MSIE6Bugs/ while(parent) { leftOffset += parent.offsetLeft; topOffset += parent.offsetTop; parent = parent.offsetParent; } return { top: topOffset, left: leftOffset }; }

×