Skip to content

Commit 8a94f08

Browse files
committed
Added deprecate utility, and reintroduced deprecated methods for this version.
1 parent c5d9566 commit 8a94f08

File tree

4 files changed

+97
-16
lines changed

4 files changed

+97
-16
lines changed

build/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"source": [
33
"../src/createjs/utils/extend.js",
44
"../src/createjs/utils/promote.js",
5+
"../src/createjs/utils/deprecate.js",
56
"../src/createjs/events/Event.js",
67
"../src/createjs/events/EventDispatcher.js",
78
"../src/createjs/utils/Ticker.js",

src/createjs/utils/Ticker.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ this.createjs = this.createjs||{};
143143
// public static properties:
144144
/**
145145
* Specifies the timing api (setTimeout or requestAnimationFrame) and mode to use. See
146-
* {{#crossLink "Ticker/TIMEOUT"}}{{/crossLink}}, {{#crossLink "Ticker/RAF"}}{{/crossLink}}, and
147-
* {{#crossLink "Ticker/RAF_SYNCHED"}}{{/crossLink}} for mode details.
146+
* {{#crossLink "Ticker/TIMEOUT:property"}}{{/crossLink}}, {{#crossLink "Ticker/RAF:property"}}{{/crossLink}}, and
147+
* {{#crossLink "Ticker/RAF_SYNCHED:property"}}{{/crossLink}} for mode details.
148148
* @property timingMode
149149
* @static
150150
* @type {String}
@@ -316,6 +316,8 @@ this.createjs = this.createjs||{};
316316
if (!Ticker._inited) { return; }
317317
Ticker._setupTick();
318318
};
319+
// Ticker.setInterval is @deprecated. Remove for 1.1+
320+
Ticker.setInterval = createjs.deprecate(Ticker._setInterval, "Ticker.setInterval");
319321

320322
/**
321323
* Use the {{#crossLink "Ticker/interval:property"}}{{/crossLink}} property instead.
@@ -327,6 +329,8 @@ this.createjs = this.createjs||{};
327329
Ticker._getInterval = function() {
328330
return Ticker._interval;
329331
};
332+
// Ticker.getInterval is @deprecated. Remove for 1.1+
333+
Ticker.getInterval = createjs.deprecate(Ticker._getInterval, "Ticker.getInterval");
330334

331335
/**
332336
* Use the {{#crossLink "Ticker/framerate:property"}}{{/crossLink}} property instead.
@@ -338,6 +342,8 @@ this.createjs = this.createjs||{};
338342
Ticker._setFPS = function(value) {
339343
Ticker._setInterval(1000/value);
340344
};
345+
// Ticker.setFPS is @deprecated. Remove for 1.1+
346+
Ticker.setFPS = createjs.deprecate(Ticker._setFPS, "Ticker.setFPS");
341347

342348
/**
343349
* Use the {{#crossLink "Ticker/framerate:property"}}{{/crossLink}} property instead.
@@ -349,6 +355,8 @@ this.createjs = this.createjs||{};
349355
Ticker._getFPS = function() {
350356
return 1000/Ticker._interval;
351357
};
358+
// Ticker.getFPS is @deprecated. Remove for 1.1+
359+
Ticker.getFPS = createjs.deprecate(Ticker._getFPS, "Ticker.getFPS");
352360

353361
/**
354362
* Indicates the target time (in milliseconds) between ticks. Default is 50 (20 FPS).

src/createjs/utils/deprecate.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* extend
3+
* Visit http://createjs.com/ for documentation, updates and examples.
4+
*
5+
* Copyright (c) 2010 gskinner.com, inc.
6+
*
7+
* Permission is hereby granted, free of charge, to any person
8+
* obtaining a copy of this software and associated documentation
9+
* files (the "Software"), to deal in the Software without
10+
* restriction, including without limitation the rights to use,
11+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the
13+
* Software is furnished to do so, subject to the following
14+
* conditions:
15+
*
16+
* The above copyright notice and this permission notice shall be
17+
* included in all copies or substantial portions of the Software.
18+
*
19+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26+
* OTHER DEALINGS IN THE SOFTWARE.
27+
*/
28+
29+
/**
30+
* @module CreateJS
31+
*/
32+
33+
// namespace:
34+
this.createjs = this.createjs||{};
35+
36+
/**
37+
* @class Utility Methods
38+
*/
39+
40+
/**
41+
* Wraps deprecated methods so they still be used, but throw warnings to developers.
42+
*
43+
* obj.deprecatedMethod = createjs.deprecate("Old Method Name", obj._fallbackMethod);
44+
*
45+
* The recommended approach for deprecated properties is:
46+
*
47+
* try {
48+
* Obj ect.defineProperties(object, {
49+
* readyOnlyProp: { get: createjs.deprecate("readOnlyProp", function() { return this.alternateProp; }) },
50+
* readWriteProp: {
51+
* get: createjs.deprecate("readOnlyProp", function() { return this.alternateProp; }),
52+
* set: createjs.deprecate("readOnlyProp", function(val) { this.alternateProp = val; })
53+
* });
54+
* } catch (e) {}
55+
*
56+
* @method deprecate
57+
* @param {Function} [fallbackMethod=null] A method to call when the deprecated method is used. See the example for how
58+
* @param {String} [name=null] The name of the method or property to display in the console warning.
59+
* to deprecate properties.
60+
* @return {Function} If a fallbackMethod is supplied, returns a closure that will call the fallback method after
61+
* logging the warning in the console.
62+
*/
63+
createjs.deprecate = function(fallbackMethod, name) {
64+
"use strict";
65+
return function() {
66+
console && (console.warn || console.log)("Deprecated property or method '"+name+"'. See docs for info.");
67+
return fallbackMethod && fallbackMethod.apply(this, arguments);
68+
}
69+
};

src/tweenjs/AbstractTween.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -228,39 +228,42 @@ this.createjs = this.createjs||{};
228228
// getter / setters:
229229

230230
/**
231-
* Deprecated in favor of the {{#crossLink "AbstractTween/paused:property"}}{{/crossLink}} property.
232-
* @method setPaused
231+
* Use the {{#crossLink "AbstractTween/paused:property"}}{{/crossLink}} property instead.
232+
* @method _setPaused
233233
* @param {Boolean} [value=true] Indicates whether the tween should be paused (`true`) or played (`false`).
234-
* @deprecated
235234
* @return {AbstractTween} This tween instance (for chaining calls)
235+
* @protected
236236
* @chainable
237237
*/
238-
p.setPaused = function(value) {
238+
p._setPaused = function(value) {
239239
createjs.Tween._register(this, value);
240240
return this;
241241
};
242+
p.setPaused = createjs.deprecate(p._setPaused, "AbstractTween.setPaused");
242243

243244
/**
244-
* Deprecated in favor of the {{#crossLink "AbstractTween/paused:property"}}{{/crossLink}} property.
245-
* @method getPaused
246-
* @deprecated
245+
* Use the {{#crossLink "AbstractTween/paused:property"}}{{/crossLink}} property instead.
246+
* @method _getPaused
247+
* @protected
247248
*/
248-
p.getPaused = function() {
249+
p._getPaused = function() {
249250
return this._paused;
250251
};
252+
p.getPaused = createjs.deprecate(p._getPaused, "AbstactTween.getPaused");
251253

252254
/**
253-
* Deprecated in favor of the {{#crossLink "AbstractTween/currentLabel:property"}}{{/crossLink}} property.
254-
* @method getCurrentLabel
255-
* @deprecated
255+
* Use the {{#crossLink "AbstractTween/currentLabel:property"}}{{/crossLink}} property instead.
256+
* @method _getCurrentLabel
257+
* @protected
256258
* @return {String} The name of the current label or null if there is no label
257259
**/
258-
p.getCurrentLabel = function(pos) {
260+
p._getCurrentLabel = function(pos) {
259261
var labels = this.getLabels();
260262
if (pos == null) { pos = this.position; }
261263
for (var i = 0, l = labels.length; i<l; i++) { if (pos < labels[i].position) { break; } }
262264
return (i===0) ? null : labels[i-1].label;
263265
};
266+
p.getCurrentLabel = createjs.deprecate(p._getCurrentLabel, "AbstractTween.getCurrentLabel");
264267

265268
/**
266269
* Pauses or unpauses the tween. A paused tween is removed from the global registry and is eligible for garbage
@@ -286,8 +289,8 @@ this.createjs = this.createjs||{};
286289

287290
try {
288291
Object.defineProperties(p, {
289-
paused: { set: p.setPaused, get: p.getPaused },
290-
currentLabel: { get: p.getCurrentLabel }
292+
paused: { set: p._setPaused, get: p._getPaused },
293+
currentLabel: { get: p._getCurrentLabel }
291294
});
292295
} catch (e) {}
293296

0 commit comments

Comments
 (0)