just-carousel
Advanced tools
Comparing version 0.2.0 to 0.3.0
31
index.js
@@ -63,2 +63,3 @@ /* global module, window, document */ | ||
this.slides = this.inner.children; | ||
this.slidesLength = this.slides.length; | ||
this.isMoving = false; | ||
@@ -114,2 +115,4 @@ this.collectingSpeedTimeout = 0; | ||
slideTo: function (idx, needQuick) { | ||
checkForUpdate.call(this); | ||
this.isMoving = false; | ||
@@ -153,2 +156,6 @@ this.endX = 0; | ||
update: function() { | ||
checkForUpdate.call(this); | ||
}, | ||
destroy: function () { | ||
@@ -197,8 +204,12 @@ this.root.removeEventListener('touchstart', this._onTouchStart, false); | ||
for (var i = 0; i < this.slides.length; i++) { | ||
this.slides[i].style.height = '100%'; | ||
this.slides[i].style.width = 100 / this.slides.length + '%'; | ||
this.slides[i].style.float = 'left'; | ||
applyStylesToSlide.call(this, this.slides[i]); | ||
} | ||
} | ||
function applyStylesToSlide(slide) { | ||
slide.style.height = '100%'; | ||
slide.style.width = 100 / this.slides.length + '%'; | ||
slide.style.float = 'left'; | ||
} | ||
function addEvents() { | ||
@@ -436,2 +447,16 @@ this.root.addEventListener('touchstart', this._onTouchStart, false); | ||
function checkForUpdate() { | ||
if (this.slidesLength === this.slides.length) { | ||
return; | ||
} | ||
this.slidesLength = this.slides.length; | ||
this.inner.style.width = 100 * this.slides.length + '%'; | ||
for (var i = 0; i < this.slidesLength; i++) { | ||
applyStylesToSlide.call(this, this.slides[i]); | ||
} | ||
} | ||
function nope() {} | ||
@@ -438,0 +463,0 @@ |
{ | ||
"name": "just-carousel", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Just an 1-item-on-screen carousel that works naturally like an iOS/android desktops and nothing else.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -90,2 +90,6 @@ # just-carousel | ||
### update() | ||
You can try to call it if something looks strange. it will recalculate some dimensions and reapply styles for slides. | ||
### destroy() | ||
@@ -92,0 +96,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16705
357
101