@hugeinc/panels
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -1,97 +0,24 @@ | ||
'use strict'; | ||
/*! | ||
MIT License | ||
/** | ||
* Simple Panels | ||
* @constructor | ||
* @param {[type]} container [description] | ||
* @param {[type]} options [description] | ||
*/ | ||
var Panels = function Panels(container, options) { | ||
var defaults = { | ||
activeClass: 'active', | ||
beforeClass: 'before', | ||
afterClass: 'after', | ||
animateClass: 'animating', | ||
slides: '.slide', | ||
infinite: true, | ||
speed: 400 | ||
}; | ||
Copyright (c) 2017 wes hatch | ||
this.options = Object.assign(defaults, options); | ||
this.container = typeof container === 'string' ? document.querySelector(container) : container; | ||
this.slides = this.container.querySelectorAll(this.options.slides); | ||
this.current = 0; | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
if (!this.slides.length) { return; } | ||
};; | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
/** | ||
* Transition from one slide to another | ||
* @param{integer} to The index of the slide to go to | ||
* @return {void} | ||
*/ | ||
Panels.prototype.go = function go (to) { | ||
var options = this.options, | ||
slides = this.slides, | ||
currentSlide, | ||
nextSlide, | ||
direction; | ||
// determine direction:1: backward, -1: forward. Do this before we % it | ||
direction = Math.abs(this.current - to) / (this.current - to); | ||
// calculate where we're going | ||
if (options.infinite) { | ||
to = (slides.length + (to % slides.length)) % slides.length;// eslint-disable-line no-extra-parens | ||
} else { | ||
to = Math.max(Math.min(slides.length - 1, to), 0); | ||
} | ||
// dont do nuthin if we dont need to | ||
if (to === this.current || this.sliding) { return; } | ||
// Call onSlide function, if it exists. Note: doesn't check if is a function | ||
if (options.onSlide) { options.onSlide.call(this, to, this.current); } | ||
currentSlide = slides[this.current]; | ||
nextSlide = slides[to]; | ||
// prime the slides: position the ones we're going to and moving from | ||
if (direction > 0) { | ||
nextSlide.classList.add(options.beforeClass); | ||
currentSlide.classList.add(options.afterClass); | ||
} else { | ||
nextSlide.classList.add(options.afterClass); | ||
currentSlide.classList.add(options.beforeClass); | ||
} | ||
// force a repaint to actually position "to" slide. *Important* | ||
nextSlide.offsetHeight;// jshint ignore:line | ||
// start the transition | ||
currentSlide.classList.add(options.animateClass); | ||
nextSlide.classList.add(options.animateClass); | ||
nextSlide.classList.add(options.activeClass); | ||
currentSlide.classList.remove(options.activeClass); | ||
nextSlide.classList.remove(options.beforeClass); | ||
nextSlide.classList.remove(options.afterClass); | ||
// clean up afterwards | ||
setTimeout(function() { | ||
Array.prototype.forEach.call(slides, function(slide) { | ||
slide.classList.remove(options.animateClass); | ||
slide.classList.remove(options.beforeClass); | ||
slide.classList.remove(options.afterClass); | ||
}); | ||
// this.sliding = false; | ||
}, options.speed); | ||
this.current = to; | ||
}; | ||
module.exports = Panels; | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
"use strict";var Panels=function(s,t){var e={activeClass:"active",beforeClass:"before",afterClass:"after",animateClass:"animating",slides:".slide",infinite:!0,speed:400};this.options=Object.assign(e,t),this.container="string"==typeof s?document.querySelector(s):s,this.slides=this.container.querySelectorAll(this.options.slides),this.current=0,this.slides.length};Panels.prototype.go=function(s){var t,e,a,i=this.options,l=this.slides;a=Math.abs(this.current-s)/(this.current-s),(s=i.infinite?(l.length+s%l.length)%l.length:Math.max(Math.min(l.length-1,s),0))===this.current||this.sliding||(i.onSlide&&i.onSlide.call(this,s,this.current),t=l[this.current],e=l[s],a>0?(e.classList.add(i.beforeClass),t.classList.add(i.afterClass)):(e.classList.add(i.afterClass),t.classList.add(i.beforeClass)),e.offsetHeight,t.classList.add(i.animateClass),e.classList.add(i.animateClass),e.classList.add(i.activeClass),t.classList.remove(i.activeClass),e.classList.remove(i.beforeClass),e.classList.remove(i.afterClass),setTimeout(function(){Array.prototype.forEach.call(l,function(s){s.classList.remove(i.animateClass),s.classList.remove(i.beforeClass),s.classList.remove(i.afterClass)})},i.speed),this.current=s)},module.exports=Panels; |
@@ -1,95 +0,24 @@ | ||
/** | ||
* Simple Panels | ||
* @constructor | ||
* @param {[type]} container [description] | ||
* @param {[type]} options [description] | ||
*/ | ||
var Panels = function Panels(container, options) { | ||
var defaults = { | ||
activeClass: 'active', | ||
beforeClass: 'before', | ||
afterClass: 'after', | ||
animateClass: 'animating', | ||
slides: '.slide', | ||
infinite: true, | ||
speed: 400 | ||
}; | ||
/*! | ||
MIT License | ||
this.options = Object.assign(defaults, options); | ||
this.container = typeof container === 'string' ? document.querySelector(container) : container; | ||
this.slides = this.container.querySelectorAll(this.options.slides); | ||
this.current = 0; | ||
Copyright (c) 2017 wes hatch | ||
if (!this.slides.length) { return; } | ||
};; | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
/** | ||
* Transition from one slide to another | ||
* @param{integer} to The index of the slide to go to | ||
* @return {void} | ||
*/ | ||
Panels.prototype.go = function go (to) { | ||
var options = this.options, | ||
slides = this.slides, | ||
currentSlide, | ||
nextSlide, | ||
direction; | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
// determine direction:1: backward, -1: forward. Do this before we % it | ||
direction = Math.abs(this.current - to) / (this.current - to); | ||
// calculate where we're going | ||
if (options.infinite) { | ||
to = (slides.length + (to % slides.length)) % slides.length;// eslint-disable-line no-extra-parens | ||
} else { | ||
to = Math.max(Math.min(slides.length - 1, to), 0); | ||
} | ||
// dont do nuthin if we dont need to | ||
if (to === this.current || this.sliding) { return; } | ||
// Call onSlide function, if it exists. Note: doesn't check if is a function | ||
if (options.onSlide) { options.onSlide.call(this, to, this.current); } | ||
currentSlide = slides[this.current]; | ||
nextSlide = slides[to]; | ||
// prime the slides: position the ones we're going to and moving from | ||
if (direction > 0) { | ||
nextSlide.classList.add(options.beforeClass); | ||
currentSlide.classList.add(options.afterClass); | ||
} else { | ||
nextSlide.classList.add(options.afterClass); | ||
currentSlide.classList.add(options.beforeClass); | ||
} | ||
// force a repaint to actually position "to" slide. *Important* | ||
nextSlide.offsetHeight;// jshint ignore:line | ||
// start the transition | ||
currentSlide.classList.add(options.animateClass); | ||
nextSlide.classList.add(options.animateClass); | ||
nextSlide.classList.add(options.activeClass); | ||
currentSlide.classList.remove(options.activeClass); | ||
nextSlide.classList.remove(options.beforeClass); | ||
nextSlide.classList.remove(options.afterClass); | ||
// clean up afterwards | ||
setTimeout(function() { | ||
Array.prototype.forEach.call(slides, function(slide) { | ||
slide.classList.remove(options.animateClass); | ||
slide.classList.remove(options.beforeClass); | ||
slide.classList.remove(options.afterClass); | ||
}); | ||
// this.sliding = false; | ||
}, options.speed); | ||
this.current = to; | ||
}; | ||
export default Panels; | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
var Panels=function(s,t){var e={activeClass:"active",beforeClass:"before",afterClass:"after",animateClass:"animating",slides:".slide",infinite:!0,speed:400};this.options=Object.assign(e,t),this.container="string"==typeof s?document.querySelector(s):s,this.slides=this.container.querySelectorAll(this.options.slides),this.current=0,this.slides.length};Panels.prototype.go=function(s){var t,e,a,i=this.options,l=this.slides;a=Math.abs(this.current-s)/(this.current-s),(s=i.infinite?(l.length+s%l.length)%l.length:Math.max(Math.min(l.length-1,s),0))===this.current||this.sliding||(i.onSlide&&i.onSlide.call(this,s,this.current),t=l[this.current],e=l[s],a>0?(e.classList.add(i.beforeClass),t.classList.add(i.afterClass)):(e.classList.add(i.afterClass),t.classList.add(i.beforeClass)),e.offsetHeight,t.classList.add(i.animateClass),e.classList.add(i.animateClass),e.classList.add(i.activeClass),t.classList.remove(i.activeClass),e.classList.remove(i.beforeClass),e.classList.remove(i.afterClass),setTimeout(function(){Array.prototype.forEach.call(l,function(s){s.classList.remove(i.animateClass),s.classList.remove(i.beforeClass),s.classList.remove(i.afterClass)})},i.speed),this.current=s)};export default Panels; |
@@ -1,100 +0,24 @@ | ||
var Panels = (function () { | ||
'use strict'; | ||
/*! | ||
MIT License | ||
/** | ||
* Simple Panels | ||
* @constructor | ||
* @param {[type]} container [description] | ||
* @param {[type]} options [description] | ||
*/ | ||
var Panels = function Panels(container, options) { | ||
var defaults = { | ||
activeClass: 'active', | ||
beforeClass: 'before', | ||
afterClass: 'after', | ||
animateClass: 'animating', | ||
slides: '.slide', | ||
infinite: true, | ||
speed: 400 | ||
}; | ||
Copyright (c) 2017 wes hatch | ||
this.options = Object.assign(defaults, options); | ||
this.container = typeof container === 'string' ? document.querySelector(container) : container; | ||
this.slides = this.container.querySelectorAll(this.options.slides); | ||
this.current = 0; | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
if (!this.slides.length) { return; } | ||
};; | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
/** | ||
* Transition from one slide to another | ||
* @param{integer} to The index of the slide to go to | ||
* @return {void} | ||
*/ | ||
Panels.prototype.go = function go (to) { | ||
var options = this.options, | ||
slides = this.slides, | ||
currentSlide, | ||
nextSlide, | ||
direction; | ||
// determine direction:1: backward, -1: forward. Do this before we % it | ||
direction = Math.abs(this.current - to) / (this.current - to); | ||
// calculate where we're going | ||
if (options.infinite) { | ||
to = (slides.length + (to % slides.length)) % slides.length;// eslint-disable-line no-extra-parens | ||
} else { | ||
to = Math.max(Math.min(slides.length - 1, to), 0); | ||
} | ||
// dont do nuthin if we dont need to | ||
if (to === this.current || this.sliding) { return; } | ||
// Call onSlide function, if it exists. Note: doesn't check if is a function | ||
if (options.onSlide) { options.onSlide.call(this, to, this.current); } | ||
currentSlide = slides[this.current]; | ||
nextSlide = slides[to]; | ||
// prime the slides: position the ones we're going to and moving from | ||
if (direction > 0) { | ||
nextSlide.classList.add(options.beforeClass); | ||
currentSlide.classList.add(options.afterClass); | ||
} else { | ||
nextSlide.classList.add(options.afterClass); | ||
currentSlide.classList.add(options.beforeClass); | ||
} | ||
// force a repaint to actually position "to" slide. *Important* | ||
nextSlide.offsetHeight;// jshint ignore:line | ||
// start the transition | ||
currentSlide.classList.add(options.animateClass); | ||
nextSlide.classList.add(options.animateClass); | ||
nextSlide.classList.add(options.activeClass); | ||
currentSlide.classList.remove(options.activeClass); | ||
nextSlide.classList.remove(options.beforeClass); | ||
nextSlide.classList.remove(options.afterClass); | ||
// clean up afterwards | ||
setTimeout(function() { | ||
Array.prototype.forEach.call(slides, function(slide) { | ||
slide.classList.remove(options.animateClass); | ||
slide.classList.remove(options.beforeClass); | ||
slide.classList.remove(options.afterClass); | ||
}); | ||
// this.sliding = false; | ||
}, options.speed); | ||
this.current = to; | ||
}; | ||
return Panels; | ||
}()); | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
var Panels=function(){"use strict";var s=function(s,t){var e={activeClass:"active",beforeClass:"before",afterClass:"after",animateClass:"animating",slides:".slide",infinite:!0,speed:400};this.options=Object.assign(e,t),this.container="string"==typeof s?document.querySelector(s):s,this.slides=this.container.querySelectorAll(this.options.slides),this.current=0,this.slides.length};return s.prototype.go=function(s){var t,e,a,i=this.options,l=this.slides;a=Math.abs(this.current-s)/(this.current-s),(s=i.infinite?(l.length+s%l.length)%l.length:Math.max(Math.min(l.length-1,s),0))===this.current||this.sliding||(i.onSlide&&i.onSlide.call(this,s,this.current),t=l[this.current],e=l[s],a>0?(e.classList.add(i.beforeClass),t.classList.add(i.afterClass)):(e.classList.add(i.afterClass),t.classList.add(i.beforeClass)),e.offsetHeight,t.classList.add(i.animateClass),e.classList.add(i.animateClass),e.classList.add(i.activeClass),t.classList.remove(i.activeClass),e.classList.remove(i.beforeClass),e.classList.remove(i.afterClass),setTimeout(function(){Array.prototype.forEach.call(l,function(s){s.classList.remove(i.animateClass),s.classList.remove(i.beforeClass),s.classList.remove(i.afterClass)})},i.speed),this.current=s)},s}(); |
@@ -5,3 +5,3 @@ { | ||
"author": "wes hatch", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"license": "MIT", | ||
@@ -31,8 +31,8 @@ "main": "./dist/panels.cjs.js", | ||
"http-server": "^0.9.0", | ||
"rollup": "^0.34.1", | ||
"rollup-plugin-buble": "^0.12.1", | ||
"rollup-plugin-uglify": "^1.0.1", | ||
"rollup": "^0.50.0", | ||
"rollup-plugin-buble": "^0.16.0", | ||
"rollup-plugin-uglify": "^2.0.1", | ||
"tape": "^4.6.0", | ||
"uglify-js": "^2.7.0" | ||
"uglify-es": "^3.1.3" | ||
} | ||
} |
@@ -23,3 +23,3 @@ # Panels | ||
// availble options | ||
// available options | ||
var options = { | ||
@@ -49,3 +49,3 @@ activeClass: 'active', | ||
## Support | ||
* IE9+ | ||
* IE9+ (although, now requires Object.assign polyfill) | ||
* Safari / Chrome | ||
@@ -52,0 +52,0 @@ * Firefox |
import buble from 'rollup-plugin-buble'; | ||
import uglify from 'rollup-plugin-uglify'; | ||
import { minify } from 'uglify-es'; | ||
import * as fs from 'fs'; | ||
const license = fs.readFileSync('LICENSE', 'utf8'); | ||
export default { | ||
entry: 'src/panels.js', | ||
moduleName: 'Panels', | ||
input: 'src/panels.js', | ||
output: [ | ||
{ | ||
file: 'dist/panels.cjs.js', | ||
format: 'cjs', | ||
banner: '/*!\n' + license + '*/' | ||
}, { | ||
file: 'dist/panels.es6.js', | ||
format: 'es', | ||
banner: '/*!\n' + license + '*/' | ||
}, { | ||
file: 'dist/panels.js', | ||
format: 'iife', | ||
name: 'Panels', | ||
banner: '/*!\n' + license + '*/' | ||
} | ||
], | ||
plugins: [ | ||
buble() | ||
], | ||
buble(), | ||
uglify({ | ||
output: { | ||
comments: function(node, comment) { | ||
var text = comment.value; | ||
var type = comment.type; | ||
targets: [ | ||
{ dest: 'dist/panels.cjs.js', format: 'cjs' }, | ||
{ dest: 'dist/panels.es6.js', format: 'es' }, | ||
{ dest: 'dist/panels.js', format: 'iife' } | ||
if (type == 'comment2') { | ||
return /^!/i.test(text); | ||
} | ||
} | ||
} | ||
}, minify) | ||
] | ||
}; |
/** | ||
* Simple Panels | ||
* @constructor | ||
* @param {[type]} container [description] | ||
* @param {[type]} options [description] | ||
* @param {HTMLElement} container A DOM element that is a parent to the panels. | ||
* @param {Object} options Configuration options | ||
*/ | ||
@@ -70,3 +70,3 @@ export default class Panels { | ||
// force a repaint to actually position "to" slide. *Important* | ||
nextSlide.offsetHeight; // jshint ignore:line | ||
nextSlide.offsetHeight; // eslint-disable-line | ||
@@ -89,5 +89,2 @@ // start the transition | ||
}); | ||
// this.sliding = false; | ||
}, options.speed); | ||
@@ -99,21 +96,2 @@ | ||
// /** | ||
// * Helper function. Simple way to merge objects | ||
// * @param {object} obj A list of objects to extend | ||
// * @return {object} The extended object | ||
// */ | ||
// _extend: function(obj) { | ||
// var args = Array.prototype.slice.call(arguments, 1); | ||
// for (var i = 0; i < args.length; i++) { | ||
// let source = args[i]; | ||
// if (source) { | ||
// for (var prop in source) { | ||
// obj[prop] = source[prop]; | ||
// } | ||
// } | ||
// } | ||
// return obj; | ||
// } | ||
// | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
323226
20
1492
1
1