Skip to content

Commit

Permalink
Fix issue with DOM Ready
Browse files Browse the repository at this point in the history
- add a dom-ready wrapper for jQuery
- add a dom-ready listener for vanilla
- bump package
  • Loading branch information
simeydotme committed Jul 14, 2018
1 parent 1093fe4 commit 288831f
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 33 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ rules:
semi:
- error
- always
no-console:
- off
26 changes: 17 additions & 9 deletions dist/donutty-jquery.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* donutty // Create SVG donut charts with Javascript
* @author simeydotme <simey.me@gmail.com>
* @version 1.1.0
* @version 1.1.2
* @license ISC
* @link http://simey.me
* @preserve
Expand Down Expand Up @@ -255,20 +255,28 @@

if ( typeof window.$ !== "undefined" ) {

$.fn.donutty = function( options ) {
$( function() {

return $( this ).each( function( k, el ) {
$.fn.donutty = function( options ) {

var $el = $( el ),
instance = new Donutty( el, $.extend( {}, $el.data(), options ) );
return $( this ).each( function( k, el ) {

$el.data( "donutty", instance );
var $el = $( el ),
instance = new Donutty( el, $.extend( {}, $el.data(), options ) );

});
$el.data( "donutty", instance );

};
});

};

$( "[data-donutty]" ).donutty();

});

} else {

$( "[data-donutty]" ).donutty();
console.warn( "Can't find jQuery to attach Donutty" );

}

Expand Down
4 changes: 2 additions & 2 deletions dist/donutty-jquery.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 10 additions & 6 deletions dist/donutty.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* donutty // Create SVG donut charts with Javascript
* @author simeydotme <simey.me@gmail.com>
* @version 1.1.0
* @version 1.1.2
* @license ISC
* @link http://simey.me
* @preserve
Expand Down Expand Up @@ -253,14 +253,18 @@

( function( Donutty ) {

var $donuts = document.querySelectorAll( "[data-donutty]" );
document.addEventListener("DOMContentLoaded", function() {

Array.prototype.forEach.call( $donuts , function( $el ) {
var $donuts = document.querySelectorAll( "[data-donutty]" );

var options = JSON.parse( JSON.stringify( $el.dataset ) ),
instance = new Donutty( $el, options );
Array.prototype.forEach.call( $donuts , function( $el ) {

$el.dataset.donutty = instance;
var options = JSON.parse( JSON.stringify( $el.dataset ) ),
instance = new Donutty( $el, options );

$el.dataset.donutty = instance;

});

});

Expand Down
4 changes: 2 additions & 2 deletions dist/donutty.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "donutty",
"version": "1.1.1",
"version": "1.1.2",
"description": "Create SVG donut charts with Javascript",
"main": "src/donutty.js",
"scripts": {
Expand Down
Loading

0 comments on commit 288831f

Please sign in to comment.