Skip to content

Commit

Permalink
chore: fix ie8 expected identifier issue on minified source
Browse files Browse the repository at this point in the history
  • Loading branch information
minhyeong-kim committed Dec 29, 2016
1 parent 4741624 commit 18c9833
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 40 deletions.
162 changes: 146 additions & 16 deletions dist/tui-component-animation.js
Expand Up @@ -97,9 +97,14 @@
/**
* @fileoverview Module for animations
* @author NHN Ent. FE Development team <dl_javascript@nhnent.com>
*/

/**
* @module ./anim
* @ignore
* @description Core module for animation
*/

var isArray = _codeSnippet2['default'].isArray,
map = _codeSnippet2['default'].map;

Expand Down Expand Up @@ -164,9 +169,11 @@
* @param {String} [options.easing='linear'] - easing functions {@see easing}
* @param {Function} [options.frame] - invoking each frames. you can manipulate specific element by this function
* the arguments passed with same sequence with `from`, `to` option values
* @param {Function} [options.done] - invoked once at end of animation
* @param {Function} [options.complete] - invoked once at end of animation
* @returns {Object} animation runner
* @tutorial example1
* @tutorial example2
* @tutorial example3
* @example
* // Initialize animation runner
* var runner = tui.component.animation.anim({
Expand All @@ -176,13 +183,13 @@
* easing: 'easeInOut',
* // manipulate x, y position
* frame: function(x, y) {
* dom.css(box, {
* $box.css({
* left: x + 'px',
* top: y + 'px'
* });
* },
* done: function() {
* dom.css(box, {
* complete: function() {
* $box.css({
* backgroundColor: 'red'
* });
* }
Expand All @@ -191,8 +198,8 @@
* // Run animation
* runner.run();
*
* // If browser support Promise `run()` return it, otherwise return `null`
* // So below line is throw an errors. use carefully
* // If browser support Promise then method `run()` is return it, otherwise it return `null`
* // So below line has be possible throw an errors. use carefully
* runner.run().then(function() {console.log('done!');});
*/
function anim() {
Expand Down Expand Up @@ -228,7 +235,7 @@
function runner(resolve, start) {
return function tick() {
var elapsed = new Date() - start;
var progress = Math.min(1, elapsed / duration);
var progress = Math.min(1, elapsed / duration || 0);
var values = map(from, function (val, idx) {
return diffs[idx] * easing(progress) + val;
});
Expand Down Expand Up @@ -280,40 +287,163 @@
var abs = Math.abs,
pow = Math.pow;

/**
* @module ./easing
* @ignore
* @description
* Easing fomulars are based on Gaëtan Renaudeau and Johan Lindell's gist
* https://gist.github.com/gre/1650294
*/

/**
* High order function for ease-in
* @param {Number} p - for using `pow(p)` to calculate accelerate factor
* @returns {Function}
*/

function _easeIn(p) {
return function (t) {
return pow(t, p);
};
return function (t) {
return pow(t, p);
};
}

/**
* High order function for ease-out
* @param {Number} p - for using `pow(p)` to calculate accelerate factor
* @returns {Function}
*/
function _easeOut(p) {
return function (t) {
return 1 - abs(pow(t - 1, p));
};
return function (t) {
return 1 - abs(pow(t - 1, p));
};
}

/**
* High order function for ease-in-out
* @param {Number} p - for using `pow(p)` to calculate accelerate factor
* @returns {Function}
*/
function _easeInOut(p) {
return function (t) {
return t < 0.5 ? _easeIn(p)(t * 2) / 2 : _easeOut(p)(t * 2 - 1) / 2 + 0.5;
};
return function (t) {
return t < 0.5 ? _easeIn(p)(t * 2) / 2 : _easeOut(p)(t * 2 - 1) / 2 + 0.5;
};
}

/**
* no easing, no acceleration
* @method
* @param {Number} t - progress value between 0 ~ 1
* @returns {Number} calculated delta value
*/
var linear = exports.linear = _easeInOut(1);
/**
* accelerating from zero velocity
* @method
* @param {Number} t - progress value between 0 ~ 1
* @returns {Number} calculated delta value
*/
var easeInQuad = exports.easeInQuad = _easeIn(2);
/**
* decelerating to zero velocity
* @method
* @param {Number} t - progress value between 0 ~ 1
* @returns {Number} calculated delta value
*/
var easeOutQuad = exports.easeOutQuad = _easeOut(2);
/**
* acceleration until halfway, then deceleration
* @method
* @param {Number} t - progress value between 0 ~ 1
* @returns {Number} calculated delta value
*/
var easeInOutQuad = exports.easeInOutQuad = _easeInOut(2);

/**
* accelerating from zero velocity
* @method
* @param {Number} t - progress value between 0 ~ 1
* @returns {Number} calculated delta value
*/
var easeIn = exports.easeIn = easeInQuad;
/**
* decelerating to zero velocity
* @method
* @param {Number} t - progress value between 0 ~ 1
* @returns {Number} calculated delta value
*/
var easeOut = exports.easeOut = easeOutQuad;
/**
* acceleration until halfway, then deceleration
* @method
* @param {Number} t - progress value between 0 ~ 1
* @returns {Number} calculated delta value
*/
var easeInOut = exports.easeInOut = easeInOutQuad;

/**
* accelerating from zero velocity
* @method
* @param {Number} t - progress value between 0 ~ 1
* @returns {Number} calculated delta value
*/
var easeInCubic = exports.easeInCubic = _easeIn(3);
/**
* decelerating to zero velocity
* @method
* @param {Number} t - progress value between 0 ~ 1
* @returns {Number} calculated delta value
*/
var easeOutCubic = exports.easeOutCubic = _easeOut(3);
/**
* acceleration until halfway, then deceleration
* @method
* @param {Number} t - progress value between 0 ~ 1
* @returns {Number} calculated delta value
*/
var easeInOutCubic = exports.easeInOutCubic = _easeInOut(3);

/**
* accelerating from zero velocity
* @method
* @param {Number} t - progress value between 0 ~ 1
* @returns {Number} calculated delta value
*/
var easeInQuart = exports.easeInQuart = _easeIn(4);
/**
* decelerating to zero velocity
* @method
* @param {Number} t - progress value between 0 ~ 1
* @returns {Number} calculated delta value
*/
var easeOutQuart = exports.easeOutQuart = _easeOut(4);
/**
* acceleration until halfway, then deceleration
* @method
* @param {Number} t - progress value between 0 ~ 1
* @returns {Number} calculated delta value
*/
var easeInOutQuart = exports.easeInOutQuart = _easeInOut(4);

/**
* accelerating from zero velocity
* @method
* @param {Number} t - progress value between 0 ~ 1
* @returns {Number} calculated delta value
*/
var easeInQuint = exports.easeInQuint = _easeIn(5);
/**
* decelerating to zero velocity
* @method
* @param {Number} t - progress value between 0 ~ 1
* @returns {Number} calculated delta value
*/
var easeOutQuint = exports.easeOutQuint = _easeOut(5);
/**
* acceleration until halfway, then deceleration
* @method
* @param {Number} t - progress value between 0 ~ 1
* @returns {Number} calculated delta value
*/
var easeInOutQuint = exports.easeInOutQuint = _easeInOut(5);

/***/ }
Expand Down
3 changes: 1 addition & 2 deletions dist/tui-component-animation.min.js

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

4 changes: 2 additions & 2 deletions examples/example1.html
Expand Up @@ -62,8 +62,8 @@ <h3>easeInOutQuint</h3>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="https://cdn.rawgit.com/nhnent/tui.code-snippet/1.2.2/code-snippet.min.js"></script>
<script src="../dist/tui-component-animation.js"></script>
<script src="https://rawgit.com/nhnent/tui.code-snippet/1.2.2/code-snippet.min.js"></script>
<script src="../dist/tui-component-animation.min.js"></script>
<script class="code-js">
function run(container) {
container = $(container);
Expand Down
4 changes: 2 additions & 2 deletions examples/example2.html
Expand Up @@ -28,8 +28,8 @@
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="https://cdn.rawgit.com/nhnent/tui.code-snippet/1.2.2/code-snippet.min.js"></script>
<script src="../dist/tui-component-animation.js"></script>
<script src="https://rawgit.com/nhnent/tui.code-snippet/1.2.2/code-snippet.min.js"></script>
<script src="../dist/tui-component-animation.min.js"></script>
<script class="code-js">
var container = $('.container');
var box = $('.box');
Expand Down
4 changes: 2 additions & 2 deletions examples/example3.html
Expand Up @@ -31,8 +31,8 @@
<div class="move-console"></div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="https://cdn.rawgit.com/nhnent/tui.code-snippet/1.2.2/code-snippet.min.js"></script>
<script src="../dist/tui-component-animation.js"></script>
<script src="https://rawgit.com/nhnent/tui.code-snippet/1.2.2/code-snippet.min.js"></script>
<script src="../dist/tui-component-animation.min.js"></script>
<script class="code-js">
const isSupportPromise = (typeof Promise !== "undefined") && (/\[native code\]/.test(Promise.toString()));

Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -7,7 +7,7 @@
"test": "NODE_ENV=test karma start karma.conf.local.js",
"test:p": "NODE_ENV=test karma start karma.conf.private.js",
"test:bs": "NODE_ENV=test karma start karma.conf.bs.js",
"bundle": "webpack && NODE_ENV=production webpack -p",
"bundle": "webpack && uglifyjs dist/tui-component-animation.js --support-ie8 -c -m -o dist/tui-component-animation.min.js",
"dev": "webpack-dev-server --devtool=#source-map",
"dev:test": "karma start --no-single-run --auto-watch",
"doc": "jsdoc -c jsdoc.json && mkdir -p doc/dist && cp -f dist/tui-component-animation.js doc/dist"
Expand All @@ -22,7 +22,7 @@
"babel-core": "^6.18.2",
"babel-eslint": "^7.1.0",
"babel-loader": "^6.2.7",
"babel-plugin-istanbul": "^2.0.3",
"babel-plugin-istanbul": "^3.0.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.18.0",
"babel-plugin-transform-es3-member-expression-literals": "^6.8.0",
"babel-plugin-transform-es3-property-literals": "^6.8.0",
Expand Down
14 changes: 0 additions & 14 deletions webpack.config.js
@@ -1,5 +1,4 @@
const webpack = require('webpack');
const isProduction = process.env.NODE_ENV === 'production';
const pkg = require('./package.json');

const config = {
Expand All @@ -25,17 +24,4 @@ const config = {
]
};

if (isProduction) {
config.output.filename = `${pkg.name}.min.js`;

const uglifyJS = new webpack.optimize.UglifyJsPlugin({
compress: {
drop_console: true,
warnings: false
}
});

config.plugins.push(uglifyJS);
}

module.exports = config;

0 comments on commit 18c9833

Please sign in to comment.