gunter-kgd 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/common/dropdown.vue +227 -0
- package/components/common/loading.vue +67 -0
- package/components/gante_test/auto-scroll.js +32 -0
- package/components/gante_test/calendar.vue +257 -0
- package/components/gante_test/commit.js +2 -0
- package/components/gante_test/gante-drag-circle.vue +151 -0
- package/components/gante_test/gante-gc-item-content.vue +442 -0
- package/components/gante_test/gante-gc-item.vue +95 -0
- package/components/gante_test/gante-gc.vue +534 -0
- package/components/gante_test/gante-split.vue +125 -0
- package/components/gante_test/gante-table-td.vue +263 -0
- package/components/gante_test/gante-table-tr.vue +159 -0
- package/components/gante_test/gante-table.vue +349 -0
- package/components/gante_test/gante.vue +894 -0
- package/components/gante_test/gante_op.js +112 -0
- package/components/gante_test/requestAnimation.js +49 -0
- package/components/gante_test/resize.js +80 -0
- package/components/gante_test/search_last_width.js +27 -0
- package/gante.vue +9 -9
- package/index.js +1 -1
- package/package.json +3 -2
- package/utils/click-outside.js +18 -0
- package/utils/public.js +94 -0
- package/utils/requestAnimation.js +49 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
|
|
2
|
+
export default {
|
|
3
|
+
data(){
|
|
4
|
+
return{
|
|
5
|
+
fullScreen: false,//是否全屏模式
|
|
6
|
+
today: '今天',
|
|
7
|
+
buttonList: [
|
|
8
|
+
{
|
|
9
|
+
value: 1,
|
|
10
|
+
text: '天'
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
value: 2,
|
|
14
|
+
text: '周'
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
value: 3,
|
|
18
|
+
text: '月'
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
value: 4,
|
|
22
|
+
text: '季'
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
value: 5,
|
|
26
|
+
text: '年'
|
|
27
|
+
},
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
mounted(){
|
|
32
|
+
document.addEventListener('fullscreenchange',this.changeScreen);
|
|
33
|
+
},
|
|
34
|
+
methods: {
|
|
35
|
+
// 回到今天
|
|
36
|
+
toToday(){
|
|
37
|
+
let today = document.getElementById('today-ganteview-column');
|
|
38
|
+
let ganteview = document.getElementsByClassName('ganteview')[0];
|
|
39
|
+
if(ganteview){
|
|
40
|
+
let left = today.offsetLeft - ganteview.clientHeight/2;
|
|
41
|
+
if(left<0){
|
|
42
|
+
left = 0
|
|
43
|
+
}
|
|
44
|
+
ganteview.scrollLeft = left;
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
//切换模式
|
|
48
|
+
trickMode(item) {
|
|
49
|
+
const nextMode = Number(item) || 1;
|
|
50
|
+
this.time_mode = nextMode;
|
|
51
|
+
this.init({time_mode: nextMode}, false);
|
|
52
|
+
},
|
|
53
|
+
//切換模式
|
|
54
|
+
op_time_mode(mode){
|
|
55
|
+
const current = Number(this.time_mode) || 1;
|
|
56
|
+
let next = current + mode;
|
|
57
|
+
if(next<=1){
|
|
58
|
+
next = 1;
|
|
59
|
+
}
|
|
60
|
+
if(next>=5){
|
|
61
|
+
next=5
|
|
62
|
+
}
|
|
63
|
+
this.time_mode = next;
|
|
64
|
+
this.init({time_mode: next}, false);
|
|
65
|
+
},
|
|
66
|
+
//全屏 退出全屏
|
|
67
|
+
toFullScreen(){
|
|
68
|
+
let element = document.documentElement;
|
|
69
|
+
// 判断是否已经是全屏
|
|
70
|
+
// 如果是全屏,退出
|
|
71
|
+
if (this.fullScreen) {
|
|
72
|
+
if (document.exitFullscreen) {
|
|
73
|
+
document.exitFullscreen();
|
|
74
|
+
} else if (document.webkitCancelFullScreen) {
|
|
75
|
+
document.webkitCancelFullScreen();
|
|
76
|
+
} else if (document.mozCancelFullScreen) {
|
|
77
|
+
document.mozCancelFullScreen();
|
|
78
|
+
} else if (document.msExitFullscreen) {
|
|
79
|
+
document.msExitFullscreen();
|
|
80
|
+
}
|
|
81
|
+
console.log('已还原!');
|
|
82
|
+
} else { // 否则,进入全屏
|
|
83
|
+
if (element.requestFullscreen) {
|
|
84
|
+
element.requestFullscreen();
|
|
85
|
+
} else if (element.webkitRequestFullScreen) {
|
|
86
|
+
element.webkitRequestFullScreen();
|
|
87
|
+
} else if (element.mozRequestFullScreen) {
|
|
88
|
+
element.mozRequestFullScreen();
|
|
89
|
+
} else if (element.msRequestFullscreen) {
|
|
90
|
+
// IE11
|
|
91
|
+
element.msRequestFullscreen();
|
|
92
|
+
}
|
|
93
|
+
console.log('已全屏!');
|
|
94
|
+
}
|
|
95
|
+
// 改变当前全屏状态
|
|
96
|
+
this.fullScreen = !this.fullScreen;
|
|
97
|
+
},
|
|
98
|
+
changeScreen(){
|
|
99
|
+
if (document.fullscreenElement) {
|
|
100
|
+
this.fullScreen = true;
|
|
101
|
+
} else {
|
|
102
|
+
this.fullScreen = false;
|
|
103
|
+
}
|
|
104
|
+
setTimeout(()=>{
|
|
105
|
+
this.init({}, false);
|
|
106
|
+
},500)
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
destroyed(){
|
|
110
|
+
document.removeEventListener('fullscreenchange',this.changeScreen);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const callbackList = []
|
|
2
|
+
|
|
3
|
+
const find = (list, predicate) => {
|
|
4
|
+
for (let index = 0; index < list.length; index++) {
|
|
5
|
+
if (predicate(list[index], index, list)) {
|
|
6
|
+
return list[index]
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return null
|
|
10
|
+
}
|
|
11
|
+
const findIndex = (list, predicate) => {
|
|
12
|
+
for (let index = 0; index < list.length; index++) {
|
|
13
|
+
if (predicate(list[index], index, list)) {
|
|
14
|
+
return index
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return -1
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function raf(callback) {
|
|
21
|
+
const entry = find(callbackList, item => item.callback === callback)
|
|
22
|
+
if (entry) {
|
|
23
|
+
return entry.requestId
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
const requestId = requestAnimationFrame(ts => {
|
|
27
|
+
const index = findIndex(callbackList, item => item.callback === callback)
|
|
28
|
+
callbackList.splice(index, 1)
|
|
29
|
+
callback(ts)
|
|
30
|
+
})
|
|
31
|
+
callbackList.push({
|
|
32
|
+
callback,
|
|
33
|
+
requestId,
|
|
34
|
+
})
|
|
35
|
+
return requestId
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function caf(requestId) {
|
|
39
|
+
const index = findIndex(callbackList, item => item.requestId === requestId)
|
|
40
|
+
if (~index) {
|
|
41
|
+
callbackList.splice(index, 1)
|
|
42
|
+
}
|
|
43
|
+
cancelAnimationFrame(requestId)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export {
|
|
47
|
+
raf as requestAnimationFrame,
|
|
48
|
+
caf as cancelAnimationFrame,
|
|
49
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created by Administrator on 2018/12/29.
|
|
3
|
+
*/
|
|
4
|
+
var passiveEvents = false
|
|
5
|
+
try {
|
|
6
|
+
var opts = Object.defineProperty({}, 'passive', {
|
|
7
|
+
get: function () {
|
|
8
|
+
passiveEvents = { passive: true }
|
|
9
|
+
}
|
|
10
|
+
})
|
|
11
|
+
window.addEventListener('test', null, opts)
|
|
12
|
+
} catch (e) {}
|
|
13
|
+
|
|
14
|
+
const resize = {
|
|
15
|
+
onelresize (el, handler) {
|
|
16
|
+
if (!(el instanceof HTMLElement)) {
|
|
17
|
+
throw new TypeError("Parameter 1 is not instance of 'HTMLElement'.")
|
|
18
|
+
}
|
|
19
|
+
// https://www.w3.org/TR/html/syntax.html#writing-html-documents-elements
|
|
20
|
+
if (/^(area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr|script|style|textarea|title)$/i.test(el.tagName)) {
|
|
21
|
+
throw new TypeError('Unsupported tag type. Change the tag or wrap it in a supported tag(e.g. div).')
|
|
22
|
+
}
|
|
23
|
+
if (typeof handler !== 'function') { throw new TypeError("Parameter 2 is not of type 'function'.") }
|
|
24
|
+
|
|
25
|
+
var lastWidth = el.offsetWidth || 1
|
|
26
|
+
var lastHeight = el.offsetHeight || 1
|
|
27
|
+
var maxWidth = 10000 * (lastWidth)
|
|
28
|
+
var maxHeight = 10000 * (lastHeight)
|
|
29
|
+
|
|
30
|
+
var expand = document.createElement('div')
|
|
31
|
+
expand.style.cssText = 'position:absolute;top:0;bottom:0;left:0;right:0;z-index=-10000;overflow:hidden;visibility:hidden;'
|
|
32
|
+
var shrink = expand.cloneNode(false)
|
|
33
|
+
|
|
34
|
+
var expandChild = document.createElement('div')
|
|
35
|
+
expandChild.style.cssText = 'transition:0s;animation:none;'
|
|
36
|
+
var shrinkChild = expandChild.cloneNode(false)
|
|
37
|
+
|
|
38
|
+
expandChild.style.width = maxWidth + 'px'
|
|
39
|
+
expandChild.style.height = maxHeight + 'px'
|
|
40
|
+
shrinkChild.style.width = '250%'
|
|
41
|
+
shrinkChild.style.height = '250%'
|
|
42
|
+
|
|
43
|
+
expand.appendChild(expandChild)
|
|
44
|
+
shrink.appendChild(shrinkChild)
|
|
45
|
+
el.appendChild(expand)
|
|
46
|
+
el.appendChild(shrink)
|
|
47
|
+
|
|
48
|
+
if (expand.offsetParent !== el) {
|
|
49
|
+
el.style.position = 'relative'
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
expand.scrollTop = shrink.scrollTop = maxHeight
|
|
53
|
+
expand.scrollLeft = shrink.scrollLeft = maxWidth
|
|
54
|
+
|
|
55
|
+
var newWidth = 0
|
|
56
|
+
var newHeight = 0
|
|
57
|
+
function onResize () {
|
|
58
|
+
if (newWidth !== lastWidth || newHeight !== lastHeight) {
|
|
59
|
+
lastWidth = newWidth
|
|
60
|
+
lastHeight = newHeight
|
|
61
|
+
handler()
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function onScroll () {
|
|
66
|
+
newWidth = el.offsetWidth || 1
|
|
67
|
+
newHeight = el.offsetHeight || 1
|
|
68
|
+
if (newWidth !== lastWidth || newHeight !== lastHeight) {
|
|
69
|
+
requestAnimationFrame(onResize)
|
|
70
|
+
}
|
|
71
|
+
expand.scrollTop = shrink.scrollTop = maxHeight
|
|
72
|
+
expand.scrollLeft = shrink.scrollLeft = maxWidth
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
expand.addEventListener('scroll', onScroll, passiveEvents)
|
|
76
|
+
shrink.addEventListener('scroll', onScroll, passiveEvents)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export {resize}
|
|
80
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
methods:{
|
|
3
|
+
find_attr(_width,th_data){
|
|
4
|
+
let str = 0;
|
|
5
|
+
for(let key in th_data){
|
|
6
|
+
if(th_data[key].show != false){
|
|
7
|
+
str += th_data[key].width ? Number(th_data[key].width) + 1 : 81;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
if(str < _width){
|
|
11
|
+
let last_attr = this.find_last_attr(1,th_data)
|
|
12
|
+
//为了预防不能拖动最后一个菜单所以-2\
|
|
13
|
+
console.log(last_attr)
|
|
14
|
+
let last_width = last_attr.width ? Number(last_attr.width) - 2 : 78
|
|
15
|
+
this.$set(last_attr,'width', _width - (str - last_width))
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
find_last_attr(num,th_data){
|
|
20
|
+
if(!th_data[Object.keys(th_data)[Object.keys(th_data).length - num]].is_op && th_data[Object.keys(th_data)[Object.keys(th_data).length - num]].show != false){
|
|
21
|
+
return th_data[Object.keys(th_data)[Object.keys(th_data).length - num]]
|
|
22
|
+
}else{
|
|
23
|
+
return this.find_last_attr(num+1,th_data)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
package/gante.vue
CHANGED
|
@@ -42,15 +42,15 @@
|
|
|
42
42
|
</div>
|
|
43
43
|
</template>
|
|
44
44
|
<script>
|
|
45
|
-
import ganteTable from '
|
|
46
|
-
import ganteGc from '
|
|
47
|
-
import ganteSplit from '
|
|
48
|
-
import commitEmit from '
|
|
49
|
-
import calendar from '
|
|
50
|
-
import searchLastWidth from '
|
|
51
|
-
import ganteOp from '
|
|
52
|
-
import myPublic from '
|
|
53
|
-
import dropdown from '
|
|
45
|
+
import ganteTable from './components/gante_test/gante-table.vue'
|
|
46
|
+
import ganteGc from './components/gante_test/gante-gc.vue'
|
|
47
|
+
import ganteSplit from './components/gante_test/gante-split.vue'
|
|
48
|
+
import commitEmit from './components/gante_test/commit'
|
|
49
|
+
import calendar from './components/gante_test/calendar.vue'
|
|
50
|
+
import searchLastWidth from './components/gante_test/search_last_width';
|
|
51
|
+
import ganteOp from './components/gante_test/gante_op';
|
|
52
|
+
import myPublic from './utils/public'
|
|
53
|
+
import dropdown from './components/common/dropdown.vue'
|
|
54
54
|
let number = 0 //序号
|
|
55
55
|
export default {
|
|
56
56
|
name: 'gante',
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gunter-kgd",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"main": "
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"main": "gante-vue.common.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
7
|
},
|
|
8
|
+
"keywords": [],
|
|
8
9
|
"author": "",
|
|
9
10
|
"license": "ISC",
|
|
10
11
|
"description": ""
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 点击元素外部触发事件
|
|
3
|
+
*/
|
|
4
|
+
export default {
|
|
5
|
+
bind: function (el, { value }) {
|
|
6
|
+
let onClickOutside = value
|
|
7
|
+
el.handler = function (e) {
|
|
8
|
+
if (el && !el.contains(e.target)) {
|
|
9
|
+
onClickOutside(e)
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
document.addEventListener('click', el.handler, true)
|
|
13
|
+
},
|
|
14
|
+
unbind: function (el) {
|
|
15
|
+
document.removeEventListener('click', el.handler, true)
|
|
16
|
+
el.handler = null
|
|
17
|
+
}
|
|
18
|
+
}
|
package/utils/public.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
//时间封装
|
|
3
|
+
dateFormat: {
|
|
4
|
+
//日期格式化
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param date 标准时间日期格式
|
|
8
|
+
* @param fmt 格式化格式
|
|
9
|
+
* @returns {string}
|
|
10
|
+
*/
|
|
11
|
+
format(date, fmt = 'YYYY-MM-DD HH:mm:ss') {
|
|
12
|
+
date = new Date(date).getTime();
|
|
13
|
+
date = new Date(date);
|
|
14
|
+
var o = {
|
|
15
|
+
'M+': date.getMonth() + 1,
|
|
16
|
+
'D+': date.getDate(),
|
|
17
|
+
'h+': date.getHours() % 12 === 0 ? 12 : date.getHours() % 12,
|
|
18
|
+
'H+': date.getHours(),
|
|
19
|
+
'm+': date.getMinutes(),
|
|
20
|
+
's+': date.getSeconds(),
|
|
21
|
+
'q+': Math.floor((date.getMonth() + 3) / 3),
|
|
22
|
+
'S': date.getMilliseconds()
|
|
23
|
+
}
|
|
24
|
+
var week = {
|
|
25
|
+
'0': '\u65e5',
|
|
26
|
+
'1': '\u4e00',
|
|
27
|
+
'2': '\u4e8c',
|
|
28
|
+
'3': '\u4e09',
|
|
29
|
+
'4': '\u56db',
|
|
30
|
+
'5': '\u4e94',
|
|
31
|
+
'6': '\u516d'
|
|
32
|
+
}
|
|
33
|
+
if (/(Y+)/.test(fmt)) {
|
|
34
|
+
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
|
|
35
|
+
}
|
|
36
|
+
if (/(E+)/.test(fmt)) {
|
|
37
|
+
fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? '\u661f\u671f' : '\u5468') : '') + week[date.getDay() + ''])
|
|
38
|
+
}
|
|
39
|
+
for (var k in o) {
|
|
40
|
+
if (new RegExp('(' + k + ')').test(fmt)) {
|
|
41
|
+
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return fmt
|
|
45
|
+
},
|
|
46
|
+
//格式日期兼容苹果端日期获取
|
|
47
|
+
dateReplace(date) {
|
|
48
|
+
return date.replace(/-/g, '/');
|
|
49
|
+
},
|
|
50
|
+
//首页列表格式化时间
|
|
51
|
+
getDateDiff(time, bool = false) {
|
|
52
|
+
var dateTimeStamp = Date.parse(time.replace(/-/g, '/'))
|
|
53
|
+
var minute = 1000 * 60;
|
|
54
|
+
var hour = minute * 60;
|
|
55
|
+
var day = hour * 24;
|
|
56
|
+
var halfamonth = day * 15;
|
|
57
|
+
var month = day * 30;
|
|
58
|
+
var year = month * 12;
|
|
59
|
+
var now = new Date().getTime();
|
|
60
|
+
var diffValue = now - dateTimeStamp;
|
|
61
|
+
var yearC = diffValue / year;
|
|
62
|
+
var dayC = diffValue / day;
|
|
63
|
+
var hourC = diffValue / hour;
|
|
64
|
+
var minC = diffValue / minute;
|
|
65
|
+
var result = ''
|
|
66
|
+
if (diffValue < 0) {
|
|
67
|
+
return getDayName(dateTimeStamp, hourC, minC, time)
|
|
68
|
+
} else {
|
|
69
|
+
// console.log('yearC',yearC,dateTimeStamp,year);
|
|
70
|
+
if (yearC >= 1) {
|
|
71
|
+
let year=parseInt(yearC)==1?i18n.t('common.time.year'):i18n.t('common.time.years');
|
|
72
|
+
result = parseInt(yearC) + ' ' + year;
|
|
73
|
+
} else if (dayC >= 1) {
|
|
74
|
+
let day=parseInt(dayC)==1?i18n.t('common.time.day'):i18n.t('common.time.days');
|
|
75
|
+
result = parseInt(dayC) + ' ' + day;
|
|
76
|
+
} else if (hourC >= 1) {
|
|
77
|
+
let hour=parseInt(hourC)==1?i18n.t('common.time.hour'):i18n.t('common.time.hours');
|
|
78
|
+
result = parseInt(hourC) + ' ' + hour;
|
|
79
|
+
} else if (minC >= 0) {
|
|
80
|
+
var mini = parseInt(minC)
|
|
81
|
+
if (parseInt(minC) == 0) {
|
|
82
|
+
mini = 1
|
|
83
|
+
}
|
|
84
|
+
let min=parseInt(hourC)==1?i18n.t('common.time.minute'):i18n.t('common.time.minutes');
|
|
85
|
+
result = mini + ' ' + min;
|
|
86
|
+
}
|
|
87
|
+
if (!bool) {
|
|
88
|
+
result = i18n.t('common.time.overdue') + ' ' + result
|
|
89
|
+
}
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const callbackList = []
|
|
2
|
+
|
|
3
|
+
const find = (list, predicate) => {
|
|
4
|
+
for (let index = 0; index < list.length; index++) {
|
|
5
|
+
if (predicate(list[index], index, list)) {
|
|
6
|
+
return list[index]
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return null
|
|
10
|
+
}
|
|
11
|
+
const findIndex = (list, predicate) => {
|
|
12
|
+
for (let index = 0; index < list.length; index++) {
|
|
13
|
+
if (predicate(list[index], index, list)) {
|
|
14
|
+
return index
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return -1
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function raf(callback) {
|
|
21
|
+
const entry = find(callbackList, item => item.callback === callback)
|
|
22
|
+
if (entry) {
|
|
23
|
+
return entry.requestId
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
const requestId = requestAnimationFrame(ts => {
|
|
27
|
+
const index = findIndex(callbackList, item => item.callback === callback)
|
|
28
|
+
callbackList.splice(index, 1)
|
|
29
|
+
callback(ts)
|
|
30
|
+
})
|
|
31
|
+
callbackList.push({
|
|
32
|
+
callback,
|
|
33
|
+
requestId,
|
|
34
|
+
})
|
|
35
|
+
return requestId
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function caf(requestId) {
|
|
39
|
+
const index = findIndex(callbackList, item => item.requestId === requestId)
|
|
40
|
+
if (~index) {
|
|
41
|
+
callbackList.splice(index, 1)
|
|
42
|
+
}
|
|
43
|
+
cancelAnimationFrame(requestId)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export {
|
|
47
|
+
raf as requestAnimationFrame,
|
|
48
|
+
caf as cancelAnimationFrame,
|
|
49
|
+
}
|