-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jones Warren
committed
Oct 10, 2019
1 parent
dda6649
commit cc52dee
Showing
3 changed files
with
106 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var requestAnimFrame = function () { | ||
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function ( /* function */callback, /* DOMElement */element) { | ||
window.setTimeout(callback, 1000 / 60); | ||
}; | ||
}(); | ||
|
||
var requestTimeout = exports.requestTimeout = function requestTimeout(fn, delay) { | ||
if (!window.requestAnimationFrame && !window.webkitRequestAnimationFrame && !(window.mozRequestAnimationFrame && window.mozCancelRequestAnimationFrame) && // Firefox 5 ships without cancel support | ||
!window.oRequestAnimationFrame && !window.msRequestAnimationFrame) return window.setTimeout(fn, delay); | ||
|
||
var start = new Date().getTime(), | ||
handle = new Object(); | ||
|
||
function loop() { | ||
var current = new Date().getTime(), | ||
delta = current - start; | ||
|
||
delta >= delay ? fn.call() : handle.value = requestAnimFrame(loop); | ||
}; | ||
|
||
handle.value = requestAnimFrame(loop); | ||
return handle; | ||
}; | ||
|
||
/** | ||
* Behaves the same as clearTimeout except uses cancelRequestAnimationFrame() where possible for better performance | ||
* @param {int|object} fn The callback function | ||
*/ | ||
var clearRequestTimeout = exports.clearRequestTimeout = function clearRequestTimeout(handle) { | ||
window.cancelAnimationFrame ? window.cancelAnimationFrame(handle.value) : window.webkitCancelAnimationFrame ? window.webkitCancelAnimationFrame(handle.value) : window.webkitCancelRequestAnimationFrame ? window.webkitCancelRequestAnimationFrame(handle.value) : /* Support for legacy API */ | ||
window.mozCancelRequestAnimationFrame ? window.mozCancelRequestAnimationFrame(handle.value) : window.oCancelRequestAnimationFrame ? window.oCancelRequestAnimationFrame(handle.value) : window.msCancelRequestAnimationFrame ? window.msCancelRequestAnimationFrame(handle.value) : clearTimeout(handle); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/*** webpack.config.js ***/ | ||
const path = require("path"); | ||
const HtmlWebpackPlugin = require("html-webpack-plugin"); | ||
const htmlWebpackPlugin = new HtmlWebpackPlugin({ | ||
template: path.join(__dirname, "example/index.html"), | ||
filename: "./index.html" | ||
}); | ||
module.exports = { | ||
entry: path.join(__dirname, "example/index.js"), | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.(js|jsx)$/, | ||
use: "babel-loader", | ||
exclude: /node_modules/ | ||
}, | ||
{ | ||
test: /\.scss$/, | ||
use: [ | ||
{ | ||
loader: "style-loader" // 将 JS 字符串生成为 style 节点 | ||
}, | ||
{ | ||
loader: "css-loader" // 将 CSS 转化成 CommonJS 模块 | ||
}, | ||
{ | ||
loader: "sass-loader" // 将 Sass 编译成 CSS | ||
}, | ||
{ | ||
loader: "postcss-loader" | ||
} | ||
] | ||
}, | ||
{ | ||
// 增加加载图片的规则 | ||
test: /\.(png|svg|jpg|gif|svga|mp3)$/, | ||
use: [ | ||
{ | ||
loader: "file-loader", | ||
// options: { | ||
// outputPath: "../img/", | ||
// publicPath: "/public/webpack/img/", | ||
// name: "[name][hash].[ext]" | ||
// } | ||
} | ||
] | ||
}, | ||
] | ||
}, | ||
plugins: [htmlWebpackPlugin], | ||
resolve: { | ||
extensions: [".js", ".jsx"] | ||
}, | ||
devServer: { | ||
port: 3001 | ||
}, | ||
devtool:'#eval-source-map' | ||
}; |