knockout.spin
Advanced tools
Comparing version 2.0.3 to 2.1.0
var ko = require("knockout"); | ||
var $ = require("jquery"); | ||
var objectAssign = require("object-assign"); | ||
var Promise = require("pinkie-promise"); | ||
var Spinner = require("spin.js"); | ||
@@ -8,16 +9,15 @@ | ||
// initialize the object which will return the eventual spinner | ||
var deferred = $.Deferred(); | ||
element.spinner = deferred.promise(); | ||
element.spinner = new Promise(function (resolve) { | ||
// force this to the bottom of the event queue in the rendering thread, | ||
// so we can get the computed color of the containing element after other bindings | ||
// (e.g. class, style) have evalutated. | ||
// HACK: add some more delay as the class bindings of the parent fire asynchronously. | ||
setTimeout(function () { | ||
var options = {}; | ||
options.color = element.ownerDocument.defaultView.getComputedStyle(element, null).color; | ||
objectAssign(options, ko.bindingHandlers.spinner.defaultOptions, ko.unwrap(allBindings.get("spinnerOptions"))); | ||
// force this to the bottom of the event queue in the rendering thread, | ||
// so we can get the computed color of the containing element after other bindings | ||
// (e.g. class, style) have evalutated. | ||
// HACK: add some more delay as the class bindings of the parent fire asynchronously. | ||
setTimeout(function () { | ||
var options = {}; | ||
options.color = $(element).css("color"); | ||
$.extend(options, ko.bindingHandlers.spinner.defaultOptions, ko.unwrap(allBindings.get("spinnerOptions"))); | ||
deferred.resolve(new Spinner(options)); | ||
}, 30); | ||
resolve(new Spinner(options)); | ||
}, 30); | ||
}); | ||
}, | ||
@@ -29,6 +29,6 @@ update: function (element, valueAccessor) { | ||
element.spinner.done(function (spinner) { | ||
element.spinner.then(function (spinner) { | ||
var isSpinning = result; | ||
if (isSpinning) { | ||
$(element).show(); | ||
element.style.display = ""; | ||
spinner.spin(element); | ||
@@ -40,3 +40,3 @@ } else { | ||
$(element).hide(); | ||
element.style.display = "none"; | ||
} | ||
@@ -43,0 +43,0 @@ }); |
{ | ||
"name": "knockout.spin", | ||
"version": "2.0.3", | ||
"version": "2.1.0", | ||
"description": "> Simple knockout binding that wraps [spin.js](http://fgnass.github.io/spin.js/).", | ||
@@ -23,5 +23,6 @@ "main": "knockout.spin.js", | ||
"dependencies": { | ||
"jquery": ">=1.10", | ||
"object-assign": "^4.1.1", | ||
"pinkie-promise": "^2.0.1", | ||
"spin.js": ">=1 < 3" | ||
} | ||
} |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
4245
46
4
6
+ Addedobject-assign@^4.1.1
+ Addedpinkie-promise@^2.0.1
+ Addedobject-assign@4.1.1(transitive)
+ Addedpinkie@2.0.4(transitive)
+ Addedpinkie-promise@2.0.1(transitive)
- Removedjquery@>=1.10
- Removedjquery@3.7.1(transitive)