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.0 to 1.0.1

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.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=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);
{
"name": "siema",
"version": "1.0.0",
"description": "Lightweight and simple carousel in pure JavaScript",
"version": "1.0.1",
"description": "Lightweight and simple carousel with no dependencies",
"main": "src/siema.js",

@@ -6,0 +6,0 @@ "devDependencies": {

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

Siema is a lightweight (only 1kb gziped) carousel plugin with no dependencies and no styling. As Brad Frost once said "do that shit yourself". It is 100% open source and [available on Github](https://pawelgrzybek.com/siema/). It is free to use on personal and commercial projects. Use it with your favourite module bundler or by manually injecting the script into your project.
Siema is a lightweight (only 1kb gzipped) carousel plugin with no dependencies and no styling. As Brad Frost once said "do that shit yourself". It is 100% open source and [available on Github](https://pawelgrzybek.com/siema/). It is free to use on personal and commercial projects. Use it with your favourite module bundler or by manually injecting the script into your project.

@@ -8,0 +8,0 @@ ## Installation

@@ -185,2 +185,3 @@ (function(global) {

Siema.prototype.mousedownHandler = function mousedownHandler(e) {
e.preventDefault();
e.stopPropagation();

@@ -187,0 +188,0 @@ this.pointerDown = true;

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