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

spin.js

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spin.js - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

.spmignore

47

.grunt/grunt-gh-pages/gh-pages/release/jquery.spin.js
/**
* Copyright (c) 2011-2014 Felix Gnass
* Licensed under the MIT license
* http://spin.js.org/
*/

@@ -11,6 +12,6 @@

$('#el').spin(); // Creates a default Spinner using the text color of #el.
$('#el').spin({ ... }); // Creates a Spinner using the provided options.
$('#el').spin() // Creates a default Spinner using the text color of #el.
$('#el').spin({ ... }) // Creates a Spinner using the provided options.
$('#el').spin(false); // Stops and removes the spinner.
$('#el').spin(false) // Stops and removes the spinner.

@@ -20,4 +21,4 @@ Using Presets:

$('#el').spin('small'); // Creates a 'small' Spinner using the text color of #el.
$('#el').spin('large', '#fff'); // Creates a 'large' white Spinner.
$('#el').spin('small') // Creates a 'small' Spinner using the text color of #el.
$('#el').spin('large', '#fff') // Creates a 'large' white Spinner.

@@ -28,13 +29,13 @@ Adding a custom preset:

$.fn.spin.presets.flower = {
lines: 9,
length: 10,
width: 20,
radius: 0
lines: 9
, length: 10
, width: 20
, radius: 0
}
$('#el').spin('flower', 'red');
$('#el').spin('flower', 'red')
*/
(function(factory) {
;(function(factory) {

@@ -44,8 +45,6 @@ if (typeof exports == 'object') {

factory(require('jquery'), require('spin.js'))
}
else if (typeof define == 'function' && define.amd) {
} else if (typeof define == 'function' && define.amd) {
// AMD, register as anonymous module
define(['jquery', 'spin'], factory)
}
else {
} else {
// Browser globals

@@ -61,13 +60,13 @@ if (!window.Spinner) throw new Error('Spin.js not present')

return this.each(function() {
var $this = $(this),
data = $this.data();
var $this = $(this)
, data = $this.data()
if (data.spinner) {
data.spinner.stop();
delete data.spinner;
data.spinner.stop()
delete data.spinner
}
if (opts !== false) {
opts = $.extend(
{ color: color || $this.css('color') },
$.fn.spin.presets[opts] || opts
{ color: color || $this.css('color') }
, $.fn.spin.presets[opts] || opts
)

@@ -80,7 +79,7 @@ data.spinner = new Spinner(opts).spin(this)

$.fn.spin.presets = {
tiny: { lines: 8, length: 2, width: 2, radius: 3 },
small: { lines: 8, length: 4, width: 3, radius: 5 },
large: { lines: 10, length: 8, width: 4, radius: 8 }
tiny: { lines: 8, length: 2, width: 2, radius: 3 }
, small: { lines: 8, length: 4, width: 3, radius: 5 }
, large: { lines: 10, length: 8, width: 4, radius: 8 }
}
}));
/**
* Copyright (c) 2011-2014 Felix Gnass
* Licensed under the MIT license
* http://spin.js.org/
*
* Example:
var opts = {
lines: 12, // The number of lines to draw
, length: 7, // The length of each line
, width: 5, // The line thickness
, radius: 10 // The radius of the inner circle
, scale: 1.0 // Scales overall size of the spinner
, corners: 1 // Roundness (0..1)
, color: '#000' // #rgb or #rrggbb
, opacity: 1/4 // Opacity of the lines
, rotate: 0 // Rotation offset
, direction: 1 // 1: clockwise, -1: counterclockwise
, speed: 1 // Rounds per second
, trail: 100 // Afterglow percentage
, fps: 20 // Frames per second when using setTimeout()
, zIndex: 2e9 // Use a high z-index by default
, className: 'spinner' // CSS class to assign to the element
, top: '50%' // center vertically
, left: '50%' // center horizontally
, shadow: false // Whether to render a shadow
, hwaccel: false // Whether to use hardware acceleration (might be buggy)
, position: 'absolute' // Element positioning
}
var target = document.getElementById('foo')
var spinner = new Spinner(opts).spin(target)
*/
(function(root, factory) {
;(function (root, factory) {
/* CommonJS */
if (typeof exports == 'object') module.exports = factory()
if (typeof exports == 'object') module.exports = factory()

@@ -15,5 +42,4 @@ /* AMD module */

else root.Spinner = factory()
}
(this, function() {
"use strict";
}(this, function () {
"use strict"

@@ -29,7 +55,7 @@ var prefixes = ['webkit', 'Moz', 'ms', 'O'] /* Vendor prefixes */

*/
function createEl(tag, prop) {
function createEl (tag, prop) {
var el = document.createElement(tag || 'div')
, n
for(n in prop) el[n] = prop[n]
for (n in prop) el[n] = prop[n]
return el

@@ -41,5 +67,6 @@ }

*/
function ins(parent /* child1, child2, ...*/) {
for (var i=1, n=arguments.length; i<n; i++)
function ins (parent /* child1, child2, ...*/) {
for (var i = 1, n = arguments.length; i < n; i++) {
parent.appendChild(arguments[i])
}

@@ -54,4 +81,4 @@ return parent

*/
function addAnimation(alpha, trail, i, lines) {
var name = ['opacity', trail, ~~(alpha*100), i, lines].join('-')
function addAnimation (alpha, trail, i, lines) {
var name = ['opacity', trail, ~~(alpha * 100), i, lines].join('-')
, start = 0.01 + i/lines * 100

@@ -81,3 +108,3 @@ , z = Math.max(1 - (1-alpha) / trail * (100-start), alpha)

*/
function vendor(el, prop) {
function vendor (el, prop) {
var s = el.style

@@ -88,7 +115,7 @@ , pp

prop = prop.charAt(0).toUpperCase() + prop.slice(1)
for(i=0; i<prefixes.length; i++) {
if (s[prop] !== undefined) return prop
for (i = 0; i < prefixes.length; i++) {
pp = prefixes[i]+prop
if(s[pp] !== undefined) return pp
if (s[pp] !== undefined) return pp
}
if(s[prop] !== undefined) return prop
}

@@ -99,5 +126,6 @@

*/
function css(el, prop) {
for (var n in prop)
el.style[vendor(el, n)||n] = prop[n]
function css (el, prop) {
for (var n in prop) {
el.style[vendor(el, n) || n] = prop[n]
}

@@ -110,7 +138,8 @@ return el

*/
function merge(obj) {
for (var i=1; i < arguments.length; i++) {
function merge (obj) {
for (var i = 1; i < arguments.length; i++) {
var def = arguments[i]
for (var n in def)
for (var n in def) {
if (obj[n] === undefined) obj[n] = def[n]
}
}

@@ -123,3 +152,3 @@ return obj

*/
function getColor(color, idx) {
function getColor (color, idx) {
return typeof color == 'string' ? color : color[idx % color.length]

@@ -131,24 +160,26 @@ }

var defaults = {
lines: 12, // The number of lines to draw
length: 7, // The length of each line
width: 5, // The line thickness
radius: 10, // The radius of the inner circle
scale: 1.0, // Scales overall size of the spinner
rotate: 0, // Rotation offset
corners: 1, // Roundness (0..1)
color: '#000', // #rgb or #rrggbb
direction: 1, // 1: clockwise, -1: counterclockwise
speed: 1, // Rounds per second
trail: 100, // Afterglow percentage
opacity: 1/4, // Opacity of the lines
fps: 20, // Frames per second when using setTimeout()
zIndex: 2e9, // Use a high z-index by default
className: 'spinner', // CSS class to assign to the element
top: '50%', // center vertically
left: '50%', // center horizontally
position: 'absolute' // element position
lines: 12 // The number of lines to draw
, length: 7 // The length of each line
, width: 5 // The line thickness
, radius: 10 // The radius of the inner circle
, scale: 1.0 // Scales overall size of the spinner
, corners: 1 // Roundness (0..1)
, color: '#000' // #rgb or #rrggbb
, opacity: 1/4 // Opacity of the lines
, rotate: 0 // Rotation offset
, direction: 1 // 1: clockwise, -1: counterclockwise
, speed: 1 // Rounds per second
, trail: 100 // Afterglow percentage
, fps: 20 // Frames per second when using setTimeout()
, zIndex: 2e9 // Use a high z-index by default
, className: 'spinner' // CSS class to assign to the element
, top: '50%' // center vertically
, left: '50%' // center horizontally
, shadow: false // Whether to render a shadow
, hwaccel: false // Whether to use hardware acceleration (might be buggy)
, position: 'absolute' // Element positioning
}
/** The constructor */
function Spinner(o) {
function Spinner (o) {
this.opts = merge(o || {}, Spinner.defaults, defaults)

@@ -161,3 +192,2 @@ }

merge(Spinner.prototype, {
/**

@@ -168,3 +198,3 @@ * Adds the spinner to the given target element. If this instance is already

*/
spin: function(target) {
spin: function (target) {
this.stop()

@@ -174,11 +204,14 @@

, o = self.opts
, el = self.el = css(createEl(0, {className: o.className}), {position: o.position, width: 0, zIndex: o.zIndex})
, el = self.el = createEl(null, {className: o.className})
css(el, {
left: o.left,
top: o.top
position: o.position
, width: 0
, zIndex: o.zIndex
, left: o.left
, top: o.top
})
if (target) {
target.insertBefore(el, target.firstChild||null)
target.insertBefore(el, target.firstChild || null)
}

@@ -195,8 +228,8 @@

, fps = o.fps
, f = fps/o.speed
, ostep = (1-o.opacity) / (f*o.trail / 100)
, astep = f/o.lines
, f = fps / o.speed
, ostep = (1 - o.opacity) / (f * o.trail / 100)
, astep = f / o.lines
;(function anim() {
i++;
;(function anim () {
i++
for (var j = 0; j < o.lines; j++) {

@@ -207,7 +240,7 @@ alpha = Math.max(1 - (i + (o.lines - j) * astep) % f * ostep, o.opacity)

}
self.timeout = self.el && setTimeout(anim, ~~(1000/fps))
self.timeout = self.el && setTimeout(anim, ~~(1000 / fps))
})()
}
return self
},
}

@@ -217,3 +250,3 @@ /**

*/
stop: function() {
, stop: function () {
var el = this.el

@@ -226,3 +259,3 @@ if (el) {

return this
},
}

@@ -233,3 +266,3 @@ /**

*/
lines: function(el, o) {
, lines: function (el, o) {
var i = 0

@@ -239,12 +272,12 @@ , start = (o.lines - 1) * (1 - o.direction) / 2

function fill(color, shadow) {
function fill (color, shadow) {
return css(createEl(), {
position: 'absolute',
width: o.scale*(o.length+o.width) + 'px',
height: o.scale*o.width + 'px',
background: color,
boxShadow: shadow,
transformOrigin: 'left',
transform: 'rotate(' + ~~(360/o.lines*i+o.rotate) + 'deg) translate(' + o.scale*o.radius+'px' +',0)',
borderRadius: (o.corners * o.scale*o.width>>1) + 'px'
position: 'absolute'
, width: o.scale * (o.length + o.width) + 'px'
, height: o.scale * o.width + 'px'
, background: color
, boxShadow: shadow
, transformOrigin: 'left'
, transform: 'rotate(' + ~~(360/o.lines*i + o.rotate) + 'deg) translate(' + o.scale*o.radius + 'px' + ',0)'
, borderRadius: (o.corners * o.scale * o.width >> 1) + 'px'
})

@@ -255,14 +288,14 @@ }

seg = css(createEl(), {
position: 'absolute',
top: 1+~(o.scale*o.width/2) + 'px',
transform: o.hwaccel ? 'translate3d(0,0,0)' : '',
opacity: o.opacity,
animation: useCssAnimations && addAnimation(o.opacity, o.trail, start + i * o.direction, o.lines) + ' ' + 1/o.speed + 's linear infinite'
position: 'absolute'
, top: 1 + ~(o.scale * o.width / 2) + 'px'
, transform: o.hwaccel ? 'translate3d(0,0,0)' : ''
, opacity: o.opacity
, animation: useCssAnimations && addAnimation(o.opacity, o.trail, start + i * o.direction, o.lines) + ' ' + 1 / o.speed + 's linear infinite'
})
if (o.shadow) ins(seg, css(fill('#000', '0 0 4px ' + '#000'), {top: 2+'px'}))
if (o.shadow) ins(seg, css(fill('#000', '0 0 4px #000'), {top: '2px'}))
ins(el, ins(seg, fill(getColor(o.color, i), '0 0 1px rgba(0,0,0,.1)')))
}
return el
},
}

@@ -273,3 +306,3 @@ /**

*/
opacity: function(el, i, val) {
, opacity: function (el, i, val) {
if (i < el.childNodes.length) el.childNodes[i].style.opacity = val

@@ -281,6 +314,6 @@ }

function initVML() {
function initVML () {
/* Utility function to create a VML tag */
function vml(tag, attr) {
function vml (tag, attr) {
return createEl('<' + tag + ' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">', attr)

@@ -292,32 +325,37 @@ }

Spinner.prototype.lines = function(el, o) {
var r = o.scale*(o.length+o.width)
, s = o.scale*2*r
Spinner.prototype.lines = function (el, o) {
var r = o.scale * (o.length + o.width)
, s = o.scale * 2 * r
function grp() {
function grp () {
return css(
vml('group', {
coordsize: s + ' ' + s,
coordorigin: -r + ' ' + -r
}),
{ width: s, height: s }
coordsize: s + ' ' + s
, coordorigin: -r + ' ' + -r
})
, { width: s, height: s }
)
}
var margin = -(o.width+o.length)*o.scale*2 + 'px'
var margin = -(o.width + o.length) * o.scale * 2 + 'px'
, g = css(grp(), {position: 'absolute', top: margin, left: margin})
, i
function seg(i, dx, filter) {
ins(g,
ins(css(grp(), {rotation: 360 / o.lines * i + 'deg', left: ~~dx}),
ins(css(vml('roundrect', {arcsize: o.corners}), {
width: r,
height: o.scale*o.width,
left: o.scale*o.radius,
top: -o.scale*o.width>>1,
filter: filter
}),
vml('fill', {color: getColor(o.color, i), opacity: o.opacity}),
vml('stroke', {opacity: 0}) // transparent stroke to fix color bleeding upon opacity change
function seg (i, dx, filter) {
ins(
g
, ins(
css(grp(), {rotation: 360 / o.lines * i + 'deg', left: ~~dx})
, ins(
css(
vml('roundrect', {arcsize: o.corners})
, { width: r
, height: o.scale * o.width
, left: o.scale * o.radius
, top: -o.scale * o.width >> 1
, filter: filter
}
)
, vml('fill', {color: getColor(o.color, i), opacity: o.opacity})
, vml('stroke', {opacity: 0}) // transparent stroke to fix color bleeding upon opacity change
)

@@ -329,4 +367,5 @@ )

if (o.shadow)
for (i = 1; i <= o.lines; i++)
for (i = 1; i <= o.lines; i++) {
seg(i, -2, 'progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)')
}

@@ -337,7 +376,7 @@ for (i = 1; i <= o.lines; i++) seg(i)

Spinner.prototype.opacity = function(el, i, val, o) {
Spinner.prototype.opacity = function (el, i, val, o) {
var c = el.firstChild
o = o.shadow && o.lines || 0
if (c && i+o < c.childNodes.length) {
c = c.childNodes[i+o]; c = c && c.firstChild; c = c && c.firstChild
if (c && i + o < c.childNodes.length) {
c = c.childNodes[i + o]; c = c && c.firstChild; c = c && c.firstChild
if (c) c.opacity = val

@@ -349,3 +388,3 @@ }

if (typeof document !== 'undefined') {
sheet = (function() {
sheet = (function () {
var el = createEl('style', {type : 'text/css'})

@@ -352,0 +391,0 @@ ins(document.getElementsByTagName('head')[0], el)

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

//fgnass.github.com/spin.js#v2.1.0
!function(a,b){"object"==typeof exports?module.exports=b():"function"==typeof define&&define.amd?define(b):a.Spinner=b()}(this,function(){"use strict";function a(a,b){var c,d=document.createElement(a||"div");for(c in b)d[c]=b[c];return d}function b(a){for(var b=1,c=arguments.length;c>b;b++)a.appendChild(arguments[b]);return a}function c(a,b,c,d){var e=["opacity",b,~~(100*a),c,d].join("-"),f=.01+c/d*100,g=Math.max(1-(1-a)/b*(100-f),a),h=j.substring(0,j.indexOf("Animation")).toLowerCase(),i=h&&"-"+h+"-"||"";return m[e]||(k.insertRule("@"+i+"keyframes "+e+"{0%{opacity:"+g+"}"+f+"%{opacity:"+a+"}"+(f+.01)+"%{opacity:1}"+(f+b)%100+"%{opacity:"+a+"}100%{opacity:"+g+"}}",k.cssRules.length),m[e]=1),e}function d(a,b){var c,d,e=a.style;for(b=b.charAt(0).toUpperCase()+b.slice(1),d=0;d<l.length;d++)if(c=l[d]+b,void 0!==e[c])return c;return void 0!==e[b]?b:void 0}function e(a,b){for(var c in b)a.style[d(a,c)||c]=b[c];return a}function f(a){for(var b=1;b<arguments.length;b++){var c=arguments[b];for(var d in c)void 0===a[d]&&(a[d]=c[d])}return a}function g(a,b){return"string"==typeof a?a:a[b%a.length]}function h(a){this.opts=f(a||{},h.defaults,n)}function i(){function c(b,c){return a("<"+b+' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">',c)}k.addRule(".spin-vml","behavior:url(#default#VML)"),h.prototype.lines=function(a,d){function f(){return e(c("group",{coordsize:k+" "+k,coordorigin:-j+" "+-j}),{width:k,height:k})}function h(a,h,i){b(m,b(e(f(),{rotation:360/d.lines*a+"deg",left:~~h}),b(e(c("roundrect",{arcsize:d.corners}),{width:j,height:d.scale*d.width,left:d.scale*d.radius,top:-d.scale*d.width>>1,filter:i}),c("fill",{color:g(d.color,a),opacity:d.opacity}),c("stroke",{opacity:0}))))}var i,j=d.scale*(d.length+d.width),k=2*d.scale*j,l=-(d.width+d.length)*d.scale*2+"px",m=e(f(),{position:"absolute",top:l,left:l});if(d.shadow)for(i=1;i<=d.lines;i++)h(i,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(i=1;i<=d.lines;i++)h(i);return b(a,m)},h.prototype.opacity=function(a,b,c,d){var e=a.firstChild;d=d.shadow&&d.lines||0,e&&b+d<e.childNodes.length&&(e=e.childNodes[b+d],e=e&&e.firstChild,e=e&&e.firstChild,e&&(e.opacity=c))}}var j,k,l=["webkit","Moz","ms","O"],m={},n={lines:12,length:7,width:5,radius:10,scale:1,rotate:0,corners:1,color:"#000",direction:1,speed:1,trail:100,opacity:.25,fps:20,zIndex:2e9,className:"spinner",top:"50%",left:"50%",position:"absolute"};if(h.defaults={},f(h.prototype,{spin:function(b){this.stop();var c=this,d=c.opts,f=c.el=e(a(0,{className:d.className}),{position:d.position,width:0,zIndex:d.zIndex});if(e(f,{left:d.left,top:d.top}),b&&b.insertBefore(f,b.firstChild||null),f.setAttribute("role","progressbar"),c.lines(f,c.opts),!j){var g,h=0,i=(d.lines-1)*(1-d.direction)/2,k=d.fps,l=k/d.speed,m=(1-d.opacity)/(l*d.trail/100),n=l/d.lines;!function o(){h++;for(var a=0;a<d.lines;a++)g=Math.max(1-(h+(d.lines-a)*n)%l*m,d.opacity),c.opacity(f,a*d.direction+i,g,d);c.timeout=c.el&&setTimeout(o,~~(1e3/k))}()}return c},stop:function(){var a=this.el;return a&&(clearTimeout(this.timeout),a.parentNode&&a.parentNode.removeChild(a),this.el=void 0),this},lines:function(d,f){function h(b,c){return e(a(),{position:"absolute",width:f.scale*(f.length+f.width)+"px",height:f.scale*f.width+"px",background:b,boxShadow:c,transformOrigin:"left",transform:"rotate("+~~(360/f.lines*k+f.rotate)+"deg) translate("+f.scale*f.radius+"px,0)",borderRadius:(f.corners*f.scale*f.width>>1)+"px"})}for(var i,k=0,l=(f.lines-1)*(1-f.direction)/2;k<f.lines;k++)i=e(a(),{position:"absolute",top:1+~(f.scale*f.width/2)+"px",transform:f.hwaccel?"translate3d(0,0,0)":"",opacity:f.opacity,animation:j&&c(f.opacity,f.trail,l+k*f.direction,f.lines)+" "+1/f.speed+"s linear infinite"}),f.shadow&&b(i,e(h("#000","0 0 4px #000"),{top:"2px"})),b(d,b(i,h(g(f.color,k),"0 0 1px rgba(0,0,0,.1)")));return d},opacity:function(a,b,c){b<a.childNodes.length&&(a.childNodes[b].style.opacity=c)}}),"undefined"!=typeof document){k=function(){var c=a("style",{type:"text/css"});return b(document.getElementsByTagName("head")[0],c),c.sheet||c.styleSheet}();var o=e(a("group"),{behavior:"url(#default#VML)"});!d(o,"transform")&&o.adj?i():j=d(o,"animation")}return h});
http://spin.js.org/#v2.1.1
!function(a,b){"object"==typeof exports?module.exports=b():"function"==typeof define&&define.amd?define(b):a.Spinner=b()}(this,function(){"use strict";function a(a,b){var c,d=document.createElement(a||"div");for(c in b)d[c]=b[c];return d}function b(a){for(var b=1,c=arguments.length;c>b;b++)a.appendChild(arguments[b]);return a}function c(a,b,c,d){var e=["opacity",b,~~(100*a),c,d].join("-"),f=.01+c/d*100,g=Math.max(1-(1-a)/b*(100-f),a),h=j.substring(0,j.indexOf("Animation")).toLowerCase(),i=h&&"-"+h+"-"||"";return m[e]||(k.insertRule("@"+i+"keyframes "+e+"{0%{opacity:"+g+"}"+f+"%{opacity:"+a+"}"+(f+.01)+"%{opacity:1}"+(f+b)%100+"%{opacity:"+a+"}100%{opacity:"+g+"}}",k.cssRules.length),m[e]=1),e}function d(a,b){var c,d,e=a.style;if(b=b.charAt(0).toUpperCase()+b.slice(1),void 0!==e[b])return b;for(d=0;d<l.length;d++)if(c=l[d]+b,void 0!==e[c])return c}function e(a,b){for(var c in b)a.style[d(a,c)||c]=b[c];return a}function f(a){for(var b=1;b<arguments.length;b++){var c=arguments[b];for(var d in c)void 0===a[d]&&(a[d]=c[d])}return a}function g(a,b){return"string"==typeof a?a:a[b%a.length]}function h(a){this.opts=f(a||{},h.defaults,n)}function i(){function c(b,c){return a("<"+b+' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">',c)}k.addRule(".spin-vml","behavior:url(#default#VML)"),h.prototype.lines=function(a,d){function f(){return e(c("group",{coordsize:k+" "+k,coordorigin:-j+" "+-j}),{width:k,height:k})}function h(a,h,i){b(m,b(e(f(),{rotation:360/d.lines*a+"deg",left:~~h}),b(e(c("roundrect",{arcsize:d.corners}),{width:j,height:d.scale*d.width,left:d.scale*d.radius,top:-d.scale*d.width>>1,filter:i}),c("fill",{color:g(d.color,a),opacity:d.opacity}),c("stroke",{opacity:0}))))}var i,j=d.scale*(d.length+d.width),k=2*d.scale*j,l=-(d.width+d.length)*d.scale*2+"px",m=e(f(),{position:"absolute",top:l,left:l});if(d.shadow)for(i=1;i<=d.lines;i++)h(i,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(i=1;i<=d.lines;i++)h(i);return b(a,m)},h.prototype.opacity=function(a,b,c,d){var e=a.firstChild;d=d.shadow&&d.lines||0,e&&b+d<e.childNodes.length&&(e=e.childNodes[b+d],e=e&&e.firstChild,e=e&&e.firstChild,e&&(e.opacity=c))}}var j,k,l=["webkit","Moz","ms","O"],m={},n={lines:12,length:7,width:5,radius:10,scale:1,corners:1,color:"#000",opacity:.25,rotate:0,direction:1,speed:1,trail:100,fps:20,zIndex:2e9,className:"spinner",top:"50%",left:"50%",shadow:!1,hwaccel:!1,position:"absolute"};if(h.defaults={},f(h.prototype,{spin:function(b){this.stop();var c=this,d=c.opts,f=c.el=a(null,{className:d.className});if(e(f,{position:d.position,width:0,zIndex:d.zIndex,left:d.left,top:d.top}),b&&b.insertBefore(f,b.firstChild||null),f.setAttribute("role","progressbar"),c.lines(f,c.opts),!j){var g,h=0,i=(d.lines-1)*(1-d.direction)/2,k=d.fps,l=k/d.speed,m=(1-d.opacity)/(l*d.trail/100),n=l/d.lines;!function o(){h++;for(var a=0;a<d.lines;a++)g=Math.max(1-(h+(d.lines-a)*n)%l*m,d.opacity),c.opacity(f,a*d.direction+i,g,d);c.timeout=c.el&&setTimeout(o,~~(1e3/k))}()}return c},stop:function(){var a=this.el;return a&&(clearTimeout(this.timeout),a.parentNode&&a.parentNode.removeChild(a),this.el=void 0),this},lines:function(d,f){function h(b,c){return e(a(),{position:"absolute",width:f.scale*(f.length+f.width)+"px",height:f.scale*f.width+"px",background:b,boxShadow:c,transformOrigin:"left",transform:"rotate("+~~(360/f.lines*k+f.rotate)+"deg) translate("+f.scale*f.radius+"px,0)",borderRadius:(f.corners*f.scale*f.width>>1)+"px"})}for(var i,k=0,l=(f.lines-1)*(1-f.direction)/2;k<f.lines;k++)i=e(a(),{position:"absolute",top:1+~(f.scale*f.width/2)+"px",transform:f.hwaccel?"translate3d(0,0,0)":"",opacity:f.opacity,animation:j&&c(f.opacity,f.trail,l+k*f.direction,f.lines)+" "+1/f.speed+"s linear infinite"}),f.shadow&&b(i,e(h("#000","0 0 4px #000"),{top:"2px"})),b(d,b(i,h(g(f.color,k),"0 0 1px rgba(0,0,0,.1)")));return d},opacity:function(a,b,c){b<a.childNodes.length&&(a.childNodes[b].style.opacity=c)}}),"undefined"!=typeof document){k=function(){var c=a("style",{type:"text/css"});return b(document.getElementsByTagName("head")[0],c),c.sheet||c.styleSheet}();var o=e(a("group"),{behavior:"url(#default#VML)"});!d(o,"transform")&&o.adj?i():j=d(o,"animation")}return h});
/**
* Copyright (c) 2011-2014 Felix Gnass
* Licensed under the MIT license
* http://spin.js.org/
*/

@@ -11,6 +12,6 @@

$('#el').spin(); // Creates a default Spinner using the text color of #el.
$('#el').spin({ ... }); // Creates a Spinner using the provided options.
$('#el').spin() // Creates a default Spinner using the text color of #el.
$('#el').spin({ ... }) // Creates a Spinner using the provided options.
$('#el').spin(false); // Stops and removes the spinner.
$('#el').spin(false) // Stops and removes the spinner.

@@ -20,4 +21,4 @@ Using Presets:

$('#el').spin('small'); // Creates a 'small' Spinner using the text color of #el.
$('#el').spin('large', '#fff'); // Creates a 'large' white Spinner.
$('#el').spin('small') // Creates a 'small' Spinner using the text color of #el.
$('#el').spin('large', '#fff') // Creates a 'large' white Spinner.

@@ -28,13 +29,13 @@ Adding a custom preset:

$.fn.spin.presets.flower = {
lines: 9,
length: 10,
width: 20,
radius: 0
lines: 9
, length: 10
, width: 20
, radius: 0
}
$('#el').spin('flower', 'red');
$('#el').spin('flower', 'red')
*/
(function(factory) {
;(function(factory) {

@@ -44,8 +45,6 @@ if (typeof exports == 'object') {

factory(require('jquery'), require('spin.js'))
}
else if (typeof define == 'function' && define.amd) {
} else if (typeof define == 'function' && define.amd) {
// AMD, register as anonymous module
define(['jquery', 'spin'], factory)
}
else {
} else {
// Browser globals

@@ -61,13 +60,13 @@ if (!window.Spinner) throw new Error('Spin.js not present')

return this.each(function() {
var $this = $(this),
data = $this.data();
var $this = $(this)
, data = $this.data()
if (data.spinner) {
data.spinner.stop();
delete data.spinner;
data.spinner.stop()
delete data.spinner
}
if (opts !== false) {
opts = $.extend(
{ color: color || $this.css('color') },
$.fn.spin.presets[opts] || opts
{ color: color || $this.css('color') }
, $.fn.spin.presets[opts] || opts
)

@@ -80,7 +79,7 @@ data.spinner = new Spinner(opts).spin(this)

$.fn.spin.presets = {
tiny: { lines: 8, length: 2, width: 2, radius: 3 },
small: { lines: 8, length: 4, width: 3, radius: 5 },
large: { lines: 10, length: 8, width: 4, radius: 8 }
tiny: { lines: 8, length: 2, width: 2, radius: 3 }
, small: { lines: 8, length: 4, width: 3, radius: 5 }
, large: { lines: 10, length: 8, width: 4, radius: 8 }
}
}));
{
"name": "spin.js",
"version": "2.1.0",
"version": "2.1.1",
"main": "spin.js",
"author": "Felix Gnass <fgnass@gmail.com>",
"contributors": [
"Timothy Gu <timothygu99@gmail.com>"
],
"license": "MIT",
"repository": {

@@ -25,3 +30,6 @@ "type": "git",

"grunt-bump": "0.0.13"
},
"spm": {
"main": "spin.js"
}
}

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

# spin.js
# spin.js [![JS.ORG](https://img.shields.io/badge/js.org-spin-ffb400.svg?style=flat-square)](http://js.org)

@@ -21,2 +21,2 @@ An animated CSS3 loading spinner with VML fallback for IE.

For an interactive demo and a list of all supported options please refer to the [project's homepage](http://fgnass.github.io/spin.js/).
For an interactive demo and a list of all supported options please refer to the [project's homepage](http://spin.js.org).
/**
* Copyright (c) 2011-2014 Felix Gnass
* Licensed under the MIT license
* http://spin.js.org/
*
* Example:
var opts = {
lines: 12, // The number of lines to draw
, length: 7, // The length of each line
, width: 5, // The line thickness
, radius: 10 // The radius of the inner circle
, scale: 1.0 // Scales overall size of the spinner
, corners: 1 // Roundness (0..1)
, color: '#000' // #rgb or #rrggbb
, opacity: 1/4 // Opacity of the lines
, rotate: 0 // Rotation offset
, direction: 1 // 1: clockwise, -1: counterclockwise
, speed: 1 // Rounds per second
, trail: 100 // Afterglow percentage
, fps: 20 // Frames per second when using setTimeout()
, zIndex: 2e9 // Use a high z-index by default
, className: 'spinner' // CSS class to assign to the element
, top: '50%' // center vertically
, left: '50%' // center horizontally
, shadow: false // Whether to render a shadow
, hwaccel: false // Whether to use hardware acceleration (might be buggy)
, position: 'absolute' // Element positioning
}
var target = document.getElementById('foo')
var spinner = new Spinner(opts).spin(target)
*/
(function(root, factory) {
;(function (root, factory) {
/* CommonJS */
if (typeof exports == 'object') module.exports = factory()
if (typeof exports == 'object') module.exports = factory()

@@ -15,5 +42,4 @@ /* AMD module */

else root.Spinner = factory()
}
(this, function() {
"use strict";
}(this, function () {
"use strict"

@@ -29,7 +55,7 @@ var prefixes = ['webkit', 'Moz', 'ms', 'O'] /* Vendor prefixes */

*/
function createEl(tag, prop) {
function createEl (tag, prop) {
var el = document.createElement(tag || 'div')
, n
for(n in prop) el[n] = prop[n]
for (n in prop) el[n] = prop[n]
return el

@@ -41,5 +67,6 @@ }

*/
function ins(parent /* child1, child2, ...*/) {
for (var i=1, n=arguments.length; i<n; i++)
function ins (parent /* child1, child2, ...*/) {
for (var i = 1, n = arguments.length; i < n; i++) {
parent.appendChild(arguments[i])
}

@@ -54,4 +81,4 @@ return parent

*/
function addAnimation(alpha, trail, i, lines) {
var name = ['opacity', trail, ~~(alpha*100), i, lines].join('-')
function addAnimation (alpha, trail, i, lines) {
var name = ['opacity', trail, ~~(alpha * 100), i, lines].join('-')
, start = 0.01 + i/lines * 100

@@ -81,3 +108,3 @@ , z = Math.max(1 - (1-alpha) / trail * (100-start), alpha)

*/
function vendor(el, prop) {
function vendor (el, prop) {
var s = el.style

@@ -88,7 +115,7 @@ , pp

prop = prop.charAt(0).toUpperCase() + prop.slice(1)
for(i=0; i<prefixes.length; i++) {
if (s[prop] !== undefined) return prop
for (i = 0; i < prefixes.length; i++) {
pp = prefixes[i]+prop
if(s[pp] !== undefined) return pp
if (s[pp] !== undefined) return pp
}
if(s[prop] !== undefined) return prop
}

@@ -99,5 +126,6 @@

*/
function css(el, prop) {
for (var n in prop)
el.style[vendor(el, n)||n] = prop[n]
function css (el, prop) {
for (var n in prop) {
el.style[vendor(el, n) || n] = prop[n]
}

@@ -110,7 +138,8 @@ return el

*/
function merge(obj) {
for (var i=1; i < arguments.length; i++) {
function merge (obj) {
for (var i = 1; i < arguments.length; i++) {
var def = arguments[i]
for (var n in def)
for (var n in def) {
if (obj[n] === undefined) obj[n] = def[n]
}
}

@@ -123,3 +152,3 @@ return obj

*/
function getColor(color, idx) {
function getColor (color, idx) {
return typeof color == 'string' ? color : color[idx % color.length]

@@ -131,24 +160,26 @@ }

var defaults = {
lines: 12, // The number of lines to draw
length: 7, // The length of each line
width: 5, // The line thickness
radius: 10, // The radius of the inner circle
scale: 1.0, // Scales overall size of the spinner
rotate: 0, // Rotation offset
corners: 1, // Roundness (0..1)
color: '#000', // #rgb or #rrggbb
direction: 1, // 1: clockwise, -1: counterclockwise
speed: 1, // Rounds per second
trail: 100, // Afterglow percentage
opacity: 1/4, // Opacity of the lines
fps: 20, // Frames per second when using setTimeout()
zIndex: 2e9, // Use a high z-index by default
className: 'spinner', // CSS class to assign to the element
top: '50%', // center vertically
left: '50%', // center horizontally
position: 'absolute' // element position
lines: 12 // The number of lines to draw
, length: 7 // The length of each line
, width: 5 // The line thickness
, radius: 10 // The radius of the inner circle
, scale: 1.0 // Scales overall size of the spinner
, corners: 1 // Roundness (0..1)
, color: '#000' // #rgb or #rrggbb
, opacity: 1/4 // Opacity of the lines
, rotate: 0 // Rotation offset
, direction: 1 // 1: clockwise, -1: counterclockwise
, speed: 1 // Rounds per second
, trail: 100 // Afterglow percentage
, fps: 20 // Frames per second when using setTimeout()
, zIndex: 2e9 // Use a high z-index by default
, className: 'spinner' // CSS class to assign to the element
, top: '50%' // center vertically
, left: '50%' // center horizontally
, shadow: false // Whether to render a shadow
, hwaccel: false // Whether to use hardware acceleration (might be buggy)
, position: 'absolute' // Element positioning
}
/** The constructor */
function Spinner(o) {
function Spinner (o) {
this.opts = merge(o || {}, Spinner.defaults, defaults)

@@ -161,3 +192,2 @@ }

merge(Spinner.prototype, {
/**

@@ -168,3 +198,3 @@ * Adds the spinner to the given target element. If this instance is already

*/
spin: function(target) {
spin: function (target) {
this.stop()

@@ -174,11 +204,14 @@

, o = self.opts
, el = self.el = css(createEl(0, {className: o.className}), {position: o.position, width: 0, zIndex: o.zIndex})
, el = self.el = createEl(null, {className: o.className})
css(el, {
left: o.left,
top: o.top
position: o.position
, width: 0
, zIndex: o.zIndex
, left: o.left
, top: o.top
})
if (target) {
target.insertBefore(el, target.firstChild||null)
target.insertBefore(el, target.firstChild || null)
}

@@ -195,8 +228,8 @@

, fps = o.fps
, f = fps/o.speed
, ostep = (1-o.opacity) / (f*o.trail / 100)
, astep = f/o.lines
, f = fps / o.speed
, ostep = (1 - o.opacity) / (f * o.trail / 100)
, astep = f / o.lines
;(function anim() {
i++;
;(function anim () {
i++
for (var j = 0; j < o.lines; j++) {

@@ -207,7 +240,7 @@ alpha = Math.max(1 - (i + (o.lines - j) * astep) % f * ostep, o.opacity)

}
self.timeout = self.el && setTimeout(anim, ~~(1000/fps))
self.timeout = self.el && setTimeout(anim, ~~(1000 / fps))
})()
}
return self
},
}

@@ -217,3 +250,3 @@ /**

*/
stop: function() {
, stop: function () {
var el = this.el

@@ -226,3 +259,3 @@ if (el) {

return this
},
}

@@ -233,3 +266,3 @@ /**

*/
lines: function(el, o) {
, lines: function (el, o) {
var i = 0

@@ -239,12 +272,12 @@ , start = (o.lines - 1) * (1 - o.direction) / 2

function fill(color, shadow) {
function fill (color, shadow) {
return css(createEl(), {
position: 'absolute',
width: o.scale*(o.length+o.width) + 'px',
height: o.scale*o.width + 'px',
background: color,
boxShadow: shadow,
transformOrigin: 'left',
transform: 'rotate(' + ~~(360/o.lines*i+o.rotate) + 'deg) translate(' + o.scale*o.radius+'px' +',0)',
borderRadius: (o.corners * o.scale*o.width>>1) + 'px'
position: 'absolute'
, width: o.scale * (o.length + o.width) + 'px'
, height: o.scale * o.width + 'px'
, background: color
, boxShadow: shadow
, transformOrigin: 'left'
, transform: 'rotate(' + ~~(360/o.lines*i + o.rotate) + 'deg) translate(' + o.scale*o.radius + 'px' + ',0)'
, borderRadius: (o.corners * o.scale * o.width >> 1) + 'px'
})

@@ -255,14 +288,14 @@ }

seg = css(createEl(), {
position: 'absolute',
top: 1+~(o.scale*o.width/2) + 'px',
transform: o.hwaccel ? 'translate3d(0,0,0)' : '',
opacity: o.opacity,
animation: useCssAnimations && addAnimation(o.opacity, o.trail, start + i * o.direction, o.lines) + ' ' + 1/o.speed + 's linear infinite'
position: 'absolute'
, top: 1 + ~(o.scale * o.width / 2) + 'px'
, transform: o.hwaccel ? 'translate3d(0,0,0)' : ''
, opacity: o.opacity
, animation: useCssAnimations && addAnimation(o.opacity, o.trail, start + i * o.direction, o.lines) + ' ' + 1 / o.speed + 's linear infinite'
})
if (o.shadow) ins(seg, css(fill('#000', '0 0 4px ' + '#000'), {top: 2+'px'}))
if (o.shadow) ins(seg, css(fill('#000', '0 0 4px #000'), {top: '2px'}))
ins(el, ins(seg, fill(getColor(o.color, i), '0 0 1px rgba(0,0,0,.1)')))
}
return el
},
}

@@ -273,3 +306,3 @@ /**

*/
opacity: function(el, i, val) {
, opacity: function (el, i, val) {
if (i < el.childNodes.length) el.childNodes[i].style.opacity = val

@@ -281,6 +314,6 @@ }

function initVML() {
function initVML () {
/* Utility function to create a VML tag */
function vml(tag, attr) {
function vml (tag, attr) {
return createEl('<' + tag + ' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">', attr)

@@ -292,32 +325,37 @@ }

Spinner.prototype.lines = function(el, o) {
var r = o.scale*(o.length+o.width)
, s = o.scale*2*r
Spinner.prototype.lines = function (el, o) {
var r = o.scale * (o.length + o.width)
, s = o.scale * 2 * r
function grp() {
function grp () {
return css(
vml('group', {
coordsize: s + ' ' + s,
coordorigin: -r + ' ' + -r
}),
{ width: s, height: s }
coordsize: s + ' ' + s
, coordorigin: -r + ' ' + -r
})
, { width: s, height: s }
)
}
var margin = -(o.width+o.length)*o.scale*2 + 'px'
var margin = -(o.width + o.length) * o.scale * 2 + 'px'
, g = css(grp(), {position: 'absolute', top: margin, left: margin})
, i
function seg(i, dx, filter) {
ins(g,
ins(css(grp(), {rotation: 360 / o.lines * i + 'deg', left: ~~dx}),
ins(css(vml('roundrect', {arcsize: o.corners}), {
width: r,
height: o.scale*o.width,
left: o.scale*o.radius,
top: -o.scale*o.width>>1,
filter: filter
}),
vml('fill', {color: getColor(o.color, i), opacity: o.opacity}),
vml('stroke', {opacity: 0}) // transparent stroke to fix color bleeding upon opacity change
function seg (i, dx, filter) {
ins(
g
, ins(
css(grp(), {rotation: 360 / o.lines * i + 'deg', left: ~~dx})
, ins(
css(
vml('roundrect', {arcsize: o.corners})
, { width: r
, height: o.scale * o.width
, left: o.scale * o.radius
, top: -o.scale * o.width >> 1
, filter: filter
}
)
, vml('fill', {color: getColor(o.color, i), opacity: o.opacity})
, vml('stroke', {opacity: 0}) // transparent stroke to fix color bleeding upon opacity change
)

@@ -329,4 +367,5 @@ )

if (o.shadow)
for (i = 1; i <= o.lines; i++)
for (i = 1; i <= o.lines; i++) {
seg(i, -2, 'progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)')
}

@@ -337,7 +376,7 @@ for (i = 1; i <= o.lines; i++) seg(i)

Spinner.prototype.opacity = function(el, i, val, o) {
Spinner.prototype.opacity = function (el, i, val, o) {
var c = el.firstChild
o = o.shadow && o.lines || 0
if (c && i+o < c.childNodes.length) {
c = c.childNodes[i+o]; c = c && c.firstChild; c = c && c.firstChild
if (c && i + o < c.childNodes.length) {
c = c.childNodes[i + o]; c = c && c.firstChild; c = c && c.firstChild
if (c) c.opacity = val

@@ -349,3 +388,3 @@ }

if (typeof document !== 'undefined') {
sheet = (function() {
sheet = (function () {
var el = createEl('style', {type : 'text/css'})

@@ -352,0 +391,0 @@ ins(document.getElementsByTagName('head')[0], el)

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

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

Sorry, the diff of this file is not supported yet

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