Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

siema

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

siema - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

2

dist/siema.min.js

@@ -1,1 +0,1 @@

"use strict";var _extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(t[s]=i[s])}return t};!function(t){function e(t){var e=this,i={selector:".siema",duration:200,easing:"ease-out",perPage:1,startIndex:0,draggable:!0,threshold:20,loop:!1};this.config=_extends(i,t),this.selector=document.querySelector(this.config.selector),this.selectorWidth=this.selector.getBoundingClientRect().width,this.innerElements=[].slice.call(this.selector.children),this.currentSlide=this.config.startIndex,this.init(),window.addEventListener("resize",function(){e.resize(),e.slideToCurrent()}),this.config.draggable&&(this.pointerDown=!1,this.drag={start:0,end:0},this.selector.addEventListener("touchstart",this.touchstartHandler.bind(this)),this.selector.addEventListener("touchend",this.touchendHandler.bind(this)),this.selector.addEventListener("touchmove",this.touchmoveHandler.bind(this),{passive:!0}),this.selector.addEventListener("mousedown",this.mousedownHandler.bind(this)),this.selector.addEventListener("mouseup",this.mouseupHandler.bind(this)),this.selector.addEventListener("mouseleave",this.mouseleaveHandler.bind(this)),this.selector.addEventListener("mousemove",this.mousemoveHandler.bind(this)))}var i=this;e.prototype.init=function(){if(null===this.selector)throw new Error("Something wrong with your sleector 😭");this.selector.style.overflow="hidden",this.sliderFrame=document.createElement("div"),this.sliderFrame.style.width=this.selectorWidth/this.config.perPage*this.innerElements.length+"px",this.sliderFrame.style.webkitTransition="all "+this.config.duration+"ms "+this.config.easing,this.sliderFrame.style.transition="all "+this.config.duration+"ms "+this.config.easing,this.config.draggable&&(this.sliderFrame.style.cursor="-webkit-grab");for(var t=document.createDocumentFragment(),e=0;e<this.innerElements.length;e++)this.innerElements[e].style.cssFloat="left",this.innerElements[e].style.float="left",this.innerElements[e].style.width=100/this.innerElements.length+"%",t.appendChild(this.innerElements[e]);this.sliderFrame.appendChild(t),this.selector.appendChild(this.sliderFrame),this.slideToCurrent()},e.prototype.prev=function(){0===this.currentSlide&&this.config.loop?this.currentSlide=this.innerElements.length-this.config.perPage:this.currentSlide=Math.max(this.currentSlide-1,0),this.slideToCurrent()},e.prototype.next=function(){this.currentSlide===this.innerElements.length-this.config.perPage&&this.config.loop?this.currentSlide=0:this.currentSlide=Math.min(this.currentSlide+1,this.innerElements.length-this.config.perPage),this.slideToCurrent()},e.prototype.goTo=function(t){i.currentSlide=Math.min(Math.max(t,0),i.innerElements.length-1),i.slideToCurrent()},e.prototype.slideToCurrent=function(){this.sliderFrame.style[s]="translate3d(-"+this.currentSlide*(this.selectorWidth/this.config.perPage)+"px, 0, 0)"},e.prototype.updateAfterDrag=function(){var t=this.drag.end-this.drag.start;t>0&&Math.abs(t)>this.config.threshold?this.prev():t<0&&Math.abs(t)>this.config.threshold&&this.next(),this.slideToCurrent()},e.prototype.resize=function(){this.selectorWidth=this.selector.getBoundingClientRect().width,this.sliderFrame.style.width=this.selectorWidth/this.config.perPage*this.innerElements.length+"px"},e.prototype.clearDrag=function(){this.drag={start:0,end:0}},e.prototype.touchstartHandler=function(t){t.stopPropagation(),this.pointerDown=!0,this.drag.start=t.touches[0].pageX},e.prototype.touchendHandler=function(t){t.stopPropagation(),this.pointerDown=!1,this.sliderFrame.style.webkitTransition="all "+this.config.duration+"ms "+this.config.easing,this.sliderFrame.style.transition="all "+this.config.duration+"ms "+this.config.easing,this.drag.end&&this.updateAfterDrag(),this.clearDrag()},e.prototype.touchmoveHandler=function(t){t.stopPropagation(),this.pointerDown&&(this.drag.end=t.touches[0].pageX,this.sliderFrame.style.webkitTransition="all 0ms "+this.config.easing,this.sliderFrame.style.transition="all 0ms "+this.config.easing,this.sliderFrame.style[s]="translate3d("+(this.currentSlide*(this.selectorWidth/this.config.perPage)+(this.drag.start-this.drag.end))*-1+"px, 0, 0)")},e.prototype.mousedownHandler=function(t){t.preventDefault(),t.stopPropagation(),this.pointerDown=!0,this.drag.start=t.pageX},e.prototype.mouseupHandler=function(t){t.stopPropagation(),this.pointerDown=!1,this.sliderFrame.style.cursor="-webkit-grab",this.sliderFrame.style.webkitTransition="all "+this.config.duration+"ms "+this.config.easing,this.sliderFrame.style.transition="all "+this.config.duration+"ms "+this.config.easing,this.drag.end&&this.updateAfterDrag(),this.clearDrag()},e.prototype.mousemoveHandler=function(t){t.preventDefault(),this.pointerDown&&(this.drag.end=t.pageX,this.sliderFrame.style.cursor="-webkit-grabbing",this.sliderFrame.style.webkitTransition="all 0ms "+this.config.easing,this.sliderFrame.style.transition="all 0ms "+this.config.easing,this.sliderFrame.style[s]="translate3d("+(this.currentSlide*(this.selectorWidth/this.config.perPage)+(this.drag.start-this.drag.end))*-1+"px, 0, 0)")},e.prototype.mouseleaveHandler=function(t){this.pointerDown&&(this.pointerDown=!1,this.drag.end=t.pageX,this.sliderFrame.style.webkitTransition="all "+this.config.duration+"ms "+this.config.easing,this.sliderFrame.style.transition="all "+this.config.duration+"ms "+this.config.easing,this.updateAfterDrag(),this.clearDrag())};var s=function(){var t=document.documentElement.style;return"string"==typeof t.transform?"transform":"WebkitTransform"}();"undefined"!=typeof module&&module.exports?module.exports=e:t.Siema=e}(window);
"use strict";var _extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(t[s]=i[s])}return t};!function(t){function e(t){var e=this,i={selector:".siema",duration:200,easing:"ease-out",perPage:1,startIndex:0,draggable:!0,threshold:20,loop:!1};this.config=_extends(i,t),this.selector="string"==typeof this.config.selector?document.querySelector(this.config.selector):this.config.selector,this.selectorWidth=this.selector.getBoundingClientRect().width,this.innerElements=[].slice.call(this.selector.children),this.currentSlide=this.config.startIndex,this.init(),window.addEventListener("resize",function(){e.resize(),e.slideToCurrent()}),this.config.draggable&&(this.pointerDown=!1,this.drag={start:0,end:0},this.selector.addEventListener("touchstart",this.touchstartHandler.bind(this)),this.selector.addEventListener("touchend",this.touchendHandler.bind(this)),this.selector.addEventListener("touchmove",this.touchmoveHandler.bind(this),{passive:!0}),this.selector.addEventListener("mousedown",this.mousedownHandler.bind(this)),this.selector.addEventListener("mouseup",this.mouseupHandler.bind(this)),this.selector.addEventListener("mouseleave",this.mouseleaveHandler.bind(this)),this.selector.addEventListener("mousemove",this.mousemoveHandler.bind(this)))}var i=this;e.prototype.init=function(){if(null===this.selector)throw new Error("Something wrong with your sleector 😭");this.selector.style.overflow="hidden",this.sliderFrame=document.createElement("div"),this.sliderFrame.style.width=this.selectorWidth/this.config.perPage*this.innerElements.length+"px",this.sliderFrame.style.webkitTransition="all "+this.config.duration+"ms "+this.config.easing,this.sliderFrame.style.transition="all "+this.config.duration+"ms "+this.config.easing,this.config.draggable&&(this.sliderFrame.style.cursor="-webkit-grab");for(var t=document.createDocumentFragment(),e=0;e<this.innerElements.length;e++)this.innerElements[e].style.cssFloat="left",this.innerElements[e].style.float="left",this.innerElements[e].style.width=100/this.innerElements.length+"%",t.appendChild(this.innerElements[e]);this.sliderFrame.appendChild(t),this.selector.appendChild(this.sliderFrame),this.slideToCurrent()},e.prototype.prev=function(){0===this.currentSlide&&this.config.loop?this.currentSlide=this.innerElements.length-this.config.perPage:this.currentSlide=Math.max(this.currentSlide-1,0),this.slideToCurrent()},e.prototype.next=function(){this.currentSlide===this.innerElements.length-this.config.perPage&&this.config.loop?this.currentSlide=0:this.currentSlide=Math.min(this.currentSlide+1,this.innerElements.length-this.config.perPage),this.slideToCurrent()},e.prototype.goTo=function(t){i.currentSlide=Math.min(Math.max(t,0),i.innerElements.length-1),i.slideToCurrent()},e.prototype.slideToCurrent=function(){this.sliderFrame.style[s]="translate3d(-"+this.currentSlide*(this.selectorWidth/this.config.perPage)+"px, 0, 0)"},e.prototype.updateAfterDrag=function(){var t=this.drag.end-this.drag.start;t>0&&Math.abs(t)>this.config.threshold?this.prev():t<0&&Math.abs(t)>this.config.threshold&&this.next(),this.slideToCurrent()},e.prototype.resize=function(){this.selectorWidth=this.selector.getBoundingClientRect().width,this.sliderFrame.style.width=this.selectorWidth/this.config.perPage*this.innerElements.length+"px"},e.prototype.clearDrag=function(){this.drag={start:0,end:0}},e.prototype.touchstartHandler=function(t){t.stopPropagation(),this.pointerDown=!0,this.drag.start=t.touches[0].pageX},e.prototype.touchendHandler=function(t){t.stopPropagation(),this.pointerDown=!1,this.sliderFrame.style.webkitTransition="all "+this.config.duration+"ms "+this.config.easing,this.sliderFrame.style.transition="all "+this.config.duration+"ms "+this.config.easing,this.drag.end&&this.updateAfterDrag(),this.clearDrag()},e.prototype.touchmoveHandler=function(t){t.stopPropagation(),this.pointerDown&&(this.drag.end=t.touches[0].pageX,this.sliderFrame.style.webkitTransition="all 0ms "+this.config.easing,this.sliderFrame.style.transition="all 0ms "+this.config.easing,this.sliderFrame.style[s]="translate3d("+(this.currentSlide*(this.selectorWidth/this.config.perPage)+(this.drag.start-this.drag.end))*-1+"px, 0, 0)")},e.prototype.mousedownHandler=function(t){t.preventDefault(),t.stopPropagation(),this.pointerDown=!0,this.drag.start=t.pageX},e.prototype.mouseupHandler=function(t){t.stopPropagation(),this.pointerDown=!1,this.sliderFrame.style.cursor="-webkit-grab",this.sliderFrame.style.webkitTransition="all "+this.config.duration+"ms "+this.config.easing,this.sliderFrame.style.transition="all "+this.config.duration+"ms "+this.config.easing,this.drag.end&&this.updateAfterDrag(),this.clearDrag()},e.prototype.mousemoveHandler=function(t){t.preventDefault(),this.pointerDown&&(this.drag.end=t.pageX,this.sliderFrame.style.cursor="-webkit-grabbing",this.sliderFrame.style.webkitTransition="all 0ms "+this.config.easing,this.sliderFrame.style.transition="all 0ms "+this.config.easing,this.sliderFrame.style[s]="translate3d("+(this.currentSlide*(this.selectorWidth/this.config.perPage)+(this.drag.start-this.drag.end))*-1+"px, 0, 0)")},e.prototype.mouseleaveHandler=function(t){this.pointerDown&&(this.pointerDown=!1,this.drag.end=t.pageX,this.sliderFrame.style.webkitTransition="all "+this.config.duration+"ms "+this.config.easing,this.sliderFrame.style.transition="all "+this.config.duration+"ms "+this.config.easing,this.updateAfterDrag(),this.clearDrag())};var s=function(){var t=document.documentElement.style;return"string"==typeof t.transform?"transform":"WebkitTransform"}();"undefined"!=typeof module&&module.exports?module.exports=e:t.Siema=e}(window);
{
"name": "siema",
"version": "1.0.1",
"version": "1.0.2",
"description": "Lightweight and simple carousel with no dependencies",

@@ -5,0 +5,0 @@ "main": "src/siema.js",

@@ -76,3 +76,3 @@ # Siema - Lightweight and simple carousel with no dependencies

- `prev()` - go to previous slide
- `goTo(i`ndex) - go to a specific slide
- `goTo(index)` - go to a specific slide
- `currentSlide` - index of the current active slide (read only)

@@ -88,3 +88,3 @@

Bug fixes are more than welcone. If you have a feature suggestion please open an issue on Github. Before sending a pull request make sure to use the 'build' task please.
Bug fixes are more than welcome. If you have a feature suggestion please open an issue on Github. Before sending a pull request make sure to use the 'build' task please.

@@ -91,0 +91,0 @@ ```bash

@@ -21,3 +21,3 @@ (function(global) {

// Create global references
this.selector = document.querySelector(this.config.selector);
this.selector = typeof this.config.selector === 'string' ? document.querySelector(this.config.selector) : this.config.selector;
this.selectorWidth = this.selector.getBoundingClientRect().width;

@@ -24,0 +24,0 @@ this.innerElements = [].slice.call(this.selector.children);

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc