Skip to content

Commit 7d21599

Browse files
committed
fix issue with jquery ready wrapper
1 parent f672ff4 commit 7d21599

File tree

5 files changed

+69
-67
lines changed

5 files changed

+69
-67
lines changed

app/build/mojs-curve-editor.js

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ return /******/ (function(modules) { // webpackBootstrap
160160
}, {
161161
key: '_vars',
162162
value: function _vars() {
163-
this.revision = '1.4.5';
163+
this.revision = '1.4.6';
164164
this.store = (0, _store2.default)();
165165

166166
this._easings = [];
@@ -177,34 +177,47 @@ return /******/ (function(modules) { // webpackBootstrap
177177
value: function _render() {
178178
var _this = this;
179179

180-
document.addEventListener('DOMContentLoaded', function () {
181-
(0, _preact.render)((0, _preact.h)(
182-
_preactRedux.Provider,
183-
{ store: _this.store },
184-
(0, _preact.h)(_curveEditor2.default, { progressLines: _this._progressLines,
185-
ref: function ref(el) {
186-
_this._el = el;
187-
} })
188-
), document.body);
180+
var doc = document;
181+
var docState = doc.readyState;
182+
if (docState === "complete" || docState === "loaded" || docState === "interactive") {
183+
return this._renderApp();
184+
}
185+
186+
doc.addEventListener('DOMContentLoaded', function () {
187+
_this._renderApp();
189188
});
190189
}
190+
}, {
191+
key: '_renderApp',
192+
value: function _renderApp() {
193+
var _this2 = this;
194+
195+
(0, _preact.render)((0, _preact.h)(
196+
_preactRedux.Provider,
197+
{ store: this.store },
198+
(0, _preact.h)(_curveEditor2.default, { progressLines: this._progressLines,
199+
ref: function ref(el) {
200+
_this2._el = el;
201+
} })
202+
), document.body);
203+
}
191204
}, {
192205
key: '_listenUnload',
193206
value: function _listenUnload() {
194-
var _this2 = this;
207+
var _this3 = this;
195208

196209
var unloadEvent = 'onpagehide' in window ? 'pagehide' : 'beforeunload';
197210
window.addEventListener(unloadEvent, function () {
198-
if (_this2._props.isSaveState) {
199-
var preState = (0, _extends3.default)({}, _this2.store.getState());
211+
if (_this3._props.isSaveState) {
212+
var preState = (0, _extends3.default)({}, _this3.store.getState());
200213

201214
delete preState.points.history;
202215
delete preState.pointControls.history;
203216
preState.progressLines.lines = [];
204217

205-
localStorage.setItem(_this2._localStorage, (0, _stringify2.default)(preState));
218+
localStorage.setItem(_this3._localStorage, (0, _stringify2.default)(preState));
206219
} else {
207-
localStorage.removeItem(_this2._localStorage);
220+
localStorage.removeItem(_this3._localStorage);
208221
}
209222
});
210223
}
@@ -236,7 +249,7 @@ return /******/ (function(modules) { // webpackBootstrap
236249
}, {
237250
key: '_compilePath',
238251
value: function _compilePath() {
239-
var _this3 = this;
252+
var _this4 = this;
240253

241254
var state = this.store.getState();
242255
var points = state.points.present;
@@ -249,10 +262,10 @@ return /******/ (function(modules) { // webpackBootstrap
249262

250263
clearTimeout(this._tm);
251264
this._tm = setTimeout(function () {
252-
if (_this3._prevPath !== path) {
253-
_this3._prevPath = path;
254-
_this3._easing = mojs.easing.path(path);
255-
_this3._fireOnChange(path);
265+
if (_this4._prevPath !== path) {
266+
_this4._prevPath = path;
267+
_this4._easing = mojs.easing.path(path);
268+
_this4._fireOnChange(path);
256269
}
257270
}, 40);
258271
}
@@ -302,25 +315,25 @@ return /******/ (function(modules) { // webpackBootstrap
302315
}, {
303316
key: 'getEasing',
304317
value: function getEasing() {
305-
var _this4 = this;
318+
var _this5 = this;
306319

307320
var o = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
308321

309322
// get the easing function regarding reverse options
310323
var fun = function () {
311-
var i = _this4._easings.length;
324+
var i = _this5._easings.length;
312325
return function (k) {
313-
_this4._updateProgressLine(k, i, _this4._progressLines);
314-
var transform = _this4._easings[i].options.transform;
315-
return transform ? transform(_this4._easing(k)) : _this4._easing(k);
326+
_this5._updateProgressLine(k, i, _this5._progressLines);
327+
var transform = _this5._easings[i].options.transform;
328+
return transform ? transform(_this5._easing(k)) : _this5._easing(k);
316329
};
317330
}();
318331

319332
this.store.dispatch({ type: 'ADD_PROGRESS_LINE', data: {} });
320333
this._easings.push({ options: o, easing: fun });
321334

322335
(0, _defer2.default)(function () {
323-
_this4._fireOnChange(_this4._prevPath);
336+
_this5._fireOnChange(_this5._prevPath);
324337
});
325338
return fun;
326339
}

app/build/mojs-curve-editor.min.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/index.html

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -66,37 +66,14 @@
6666
<script src="../node_modules/mojs-player/build/mojs-player.js" charset="utf-8"></script>
6767
<script src="build/mojs-curve-editor.js" charset="utf-8"></script>
6868

69-
<script>
70-
71-
72-
73-
const mojsCurve = new MojsCurveEditor({
74-
name: 'b curve'
75-
});
76-
77-
const rect = new mojs.Shape({
78-
shape: 'rect',
79-
80-
left: {'0%':'100%'},
81-
top: 0,
82-
fill: 'none',
83-
radius: 20,
84-
stroke: { 'rgba(0,255,255, 1)' : 'magenta', easing: mojsCurve.getEasing() },
85-
strokeWidth: { 10: 0 },
86-
angle: { 0: 180 },
87-
88-
duration: 1500,
89-
});
90-
91-
const mainTimeline = new mojs.Timeline;
92-
mainTimeline.add( rect );
93-
const mojsPlayer = new MojsPlayer({ add: mainTimeline });
94-
69+
<script type="text/javascript" src='https://code.jquery.com/jquery-3.1.1.min.js'></script>
9570

71+
<script>
9672

73+
// jQuery(function ($) { new MojsCurveEditor({ name: 'some name' }); });
74+
new MojsCurveEditor({ name: 'some name' });
9775

9876

99-
// new MojsCurveEditor({ name: 'some name' });
10077

10178
// var scaleCurve = new window.MojsCurveEditor({ name: 'curve_scale' });
10279
// var rotateCurve = new window.MojsCurveEditor({ name: 'curve_rotate' });

app/js/app.babel.jsx

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class API {
4343
}
4444

4545
_vars () {
46-
this.revision = '1.4.5';
46+
this.revision = '1.4.6';
4747
this.store = initStore();
4848

4949
this._easings = [];
@@ -57,13 +57,25 @@ class API {
5757
}
5858

5959
_render () {
60-
document.addEventListener('DOMContentLoaded', () => {
61-
render(
62-
<Provider store={this.store}>
63-
<CurveEditor progressLines = {this._progressLines}
64-
ref={ (el) => { this._el = el; }} />
65-
</Provider>, document.body);
66-
});
60+
const doc = document;
61+
const docState = doc.readyState;
62+
if (docState === "complete" ||
63+
docState === "loaded" ||
64+
docState === "interactive") {
65+
return this._renderApp();
66+
}
67+
68+
doc.addEventListener('DOMContentLoaded', () => {this._renderApp()});
69+
}
70+
71+
_renderApp () {
72+
render(
73+
<Provider store={this.store}>
74+
<CurveEditor progressLines = {this._progressLines}
75+
ref={ (el) => { this._el = el; }} />
76+
</Provider>,
77+
document.body
78+
);
6779
}
6880

6981
_listenUnload () {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mojs-curve-editor",
3-
"version": "1.4.5",
3+
"version": "1.4.6",
44
"description": "mojs GUI for editing easing/property curves",
55
"keywords": [
66
"mojs",

0 commit comments

Comments
 (0)