immaterial-design-ripple
Version:
HTML5 Canvas based pixelated ripple effect
1,621 lines • 514 kB
JSON
{
"type": "Program",
"body": [
{
"type": "ImportDeclaration",
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"local": {
"type": "Identifier",
"name": "Promise",
"range": [
7,
14
],
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 14
}
}
},
"range": [
7,
14
],
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 14
}
}
}
],
"source": {
"type": "Literal",
"value": "bluebird",
"raw": "'bluebird'",
"range": [
20,
30
],
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 30
}
}
},
"range": [
0,
31
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 31
}
}
},
{
"type": "ImportDeclaration",
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"local": {
"type": "Identifier",
"name": "easingJs",
"range": [
39,
47
],
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 15
}
}
},
"range": [
39,
47
],
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 15
}
}
}
],
"source": {
"type": "Literal",
"value": "easing-js",
"raw": "'easing-js'",
"range": [
53,
64
],
"loc": {
"start": {
"line": 2,
"column": 21
},
"end": {
"line": 2,
"column": 32
}
}
},
"range": [
32,
65
],
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 33
}
}
},
{
"type": "ImportDeclaration",
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"local": {
"type": "Identifier",
"name": "objectAssign",
"range": [
73,
85
],
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 19
}
}
},
"range": [
73,
85
],
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 19
}
}
}
],
"source": {
"type": "Literal",
"value": "object-assign",
"raw": "'object-assign'",
"range": [
91,
106
],
"loc": {
"start": {
"line": 3,
"column": 25
},
"end": {
"line": 3,
"column": 40
}
}
},
"range": [
66,
107
],
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 41
}
},
"trailingComments": [
{
"type": "Block",
"value": "*\n* 利用可能な非同期関数でcallbackを実行する\n*\n* @function requestAnimationFrame\n* @param {Function} [callback]\n* @return undefined\n",
"range": [
109,
229
],
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 11,
"column": 2
}
}
}
]
},
{
"type": "ExportNamedDeclaration",
"declaration": {
"type": "FunctionDeclaration",
"id": {
"type": "Identifier",
"name": "requestAnimationFrame",
"range": [
246,
267
],
"loc": {
"start": {
"line": 12,
"column": 16
},
"end": {
"line": 12,
"column": 37
}
}
},
"params": [
{
"type": "Identifier",
"name": "callback",
"range": [
268,
276
],
"loc": {
"start": {
"line": 12,
"column": 38
},
"end": {
"line": 12,
"column": 46
}
}
}
],
"body": {
"type": "BlockStatement",
"body": [
{
"type": "ReturnStatement",
"argument": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "window",
"range": [
289,
295
],
"loc": {
"start": {
"line": 13,
"column": 9
},
"end": {
"line": 13,
"column": 15
}
}
},
"property": {
"type": "Identifier",
"name": "requestAnimationFrame",
"range": [
296,
317
],
"loc": {
"start": {
"line": 13,
"column": 16
},
"end": {
"line": 13,
"column": 37
}
}
},
"range": [
289,
317
],
"loc": {
"start": {
"line": 13,
"column": 9
},
"end": {
"line": 13,
"column": 37
}
}
},
"arguments": [
{
"type": "Identifier",
"name": "callback",
"range": [
318,
326
],
"loc": {
"start": {
"line": 13,
"column": 38
},
"end": {
"line": 13,
"column": 46
}
}
}
],
"range": [
289,
327
],
"loc": {
"start": {
"line": 13,
"column": 9
},
"end": {
"line": 13,
"column": 47
}
}
},
"range": [
282,
328
],
"loc": {
"start": {
"line": 13,
"column": 2
},
"end": {
"line": 13,
"column": 48
}
}
}
],
"range": [
278,
330
],
"loc": {
"start": {
"line": 12,
"column": 48
},
"end": {
"line": 14,
"column": 1
}
}
},
"generator": false,
"expression": false,
"range": [
237,
330
],
"loc": {
"start": {
"line": 12,
"column": 7
},
"end": {
"line": 14,
"column": 1
}
},
"leadingComments": [
{
"type": "Block",
"value": "*\n* 利用可能な非同期関数でcallbackを実行する\n*\n* @function requestAnimationFrame\n* @param {Function} [callback]\n* @return undefined\n",
"range": [
109,
229
],
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 11,
"column": 2
}
}
}
],
"trailingComments": [
{
"type": "Block",
"value": "*\n* 指定した要素のイベントを待つプロミスを返す\n*\n* @function promiseEvent\n* @param {Element} target イベントを取得する要素\n* @param {String} eventName 取得するイベント名\n* @return {Promise<EventTarget>} deferredEvent 取得したイベント\n",
"range": [
332,
521
],
"loc": {
"start": {
"line": 16,
"column": 0
},
"end": {
"line": 23,
"column": 2
}
}
}
]
},
"specifiers": [],
"source": null,
"range": [
230,
330
],
"loc": {
"start": {
"line": 12,
"column": 0
},
"end": {
"line": 14,
"column": 1
}
},
"leadingComments": [
{
"type": "Block",
"value": "*\n* 利用可能な非同期関数でcallbackを実行する\n*\n* @function requestAnimationFrame\n* @param {Function} [callback]\n* @return undefined\n",
"range": [
109,
229
],
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 11,
"column": 2
}
}
}
],
"trailingComments": [
{
"type": "Block",
"value": "*\n* 指定した要素のイベントを待つプロミスを返す\n*\n* @function promiseEvent\n* @param {Element} target イベントを取得する要素\n* @param {String} eventName 取得するイベント名\n* @return {Promise<EventTarget>} deferredEvent 取得したイベント\n",
"range": [
332,
521
],
"loc": {
"start": {
"line": 16,
"column": 0
},
"end": {
"line": 23,
"column": 2
}
}
}
]
},
{
"type": "ExportNamedDeclaration",
"declaration": {
"type": "FunctionDeclaration",
"id": {
"type": "Identifier",
"name": "promiseEvent",
"range": [
538,
550
],
"loc": {
"start": {
"line": 24,
"column": 16
},
"end": {
"line": 24,
"column": 28
}
}
},
"params": [
{
"type": "Identifier",
"name": "target",
"range": [
551,
557
],
"loc": {
"start": {
"line": 24,
"column": 29
},
"end": {
"line": 24,
"column": 35
}
}
},
{
"type": "Identifier",
"name": "eventName",
"range": [
559,
568
],
"loc": {
"start": {
"line": 24,
"column": 37
},
"end": {
"line": 24,
"column": 46
}
}
}
],
"body": {
"type": "BlockStatement",
"body": [
{
"type": "ReturnStatement",
"argument": {
"type": "NewExpression",
"callee": {
"type": "Identifier",
"name": "Promise",
"range": [
585,
592
],
"loc": {
"start": {
"line": 25,
"column": 13
},
"end": {
"line": 25,
"column": 20
}
}
},
"arguments": [
{
"type": "ArrowFunctionExpression",
"id": null,
"params": [
{
"type": "Identifier",
"name": "resolve",
"range": [
594,
601
],
"loc": {
"start": {
"line": 25,
"column": 22
},
"end": {
"line": 25,
"column": 29
}
}
}
],
"body": {
"type": "BlockStatement",
"body": [
{
"type": "VariableDeclaration",
"declarations": [
{
"type": "VariableDeclarator",
"id": {
"type": "Identifier",
"name": "onceListener",
"range": [
618,
630
],
"loc": {
"start": {
"line": 26,
"column": 10
},
"end": {
"line": 26,
"column": 22
}
}
},
"init": {
"type": "ArrowFunctionExpression",
"id": null,
"params": [
{
"type": "Identifier",
"name": "event",
"range": [
634,
639
],
"loc": {
"start": {
"line": 26,
"column": 26
},
"end": {
"line": 26,
"column": 31
}
}
}
],
"body": {
"type": "BlockStatement",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "target",
"range": [
652,
658
],
"loc": {
"start": {
"line": 27,
"column": 6
},
"end": {
"line": 27,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"name": "removeEventListener",
"range": [
659,
678
],
"loc": {
"start": {
"line": 27,
"column": 13
},
"end": {
"line": 27,
"column": 32
}
}
},
"range": [
652,
678
],
"loc": {
"start": {
"line": 27,
"column": 6
},
"end": {
"line": 27,
"column": 32
}
}
},
"arguments": [
{
"type": "Identifier",
"name": "eventName",
"range": [
679,
688
],
"loc": {
"start": {
"line": 27,
"column": 33
},
"end": {
"line": 27,
"column": 42
}
}
},
{
"type": "Identifier",
"name": "onceListener",
"range": [
690,
702
],
"loc": {
"start": {
"line": 27,
"column": 44
},
"end": {
"line": 27,
"column": 56
}
}
}
],
"range": [
652,
703
],
"loc": {
"start": {
"line": 27,
"column": 6
},
"end": {
"line": 27,
"column": 57
}
}
},
"range": [
652,
704
],
"loc": {
"start": {
"line": 27,
"column": 6
},
"end": {
"line": 27,
"column": 58
}
}
},
{
"type": "ExpressionStatement",
"expression": {
"type": "CallExpression",
"callee": {
"type": "Identifier",
"name": "resolve",
"range": [
712,
719
],
"loc": {
"start": {
"line": 29,
"column": 6
},
"end": {
"line": 29,
"column": 13
}
}
},
"arguments": [
{
"type": "Identifier",
"name": "event",
"range": [
720,
725
],
"loc": {
"start": {
"line": 29,
"column": 14
},
"end": {
"line": 29,
"column": 19
}
}
}
],
"range": [
712,
726
],
"loc": {
"start": {
"line": 29,
"column": 6
},
"end": {
"line": 29,
"column": 20
}
}
},
"range": [
712,
727
],
"loc": {
"start": {
"line": 29,
"column": 6
},
"end": {
"line": 29,
"column": 21
}
}
}
],
"range": [
644,
733
],
"loc": {
"start": {
"line": 26,
"column": 36
},
"end": {
"line": 30,
"column": 5
}
}
},
"generator": false,
"expression": false,
"range": [
633,
733
],
"loc": {
"start": {
"line": 26,
"column": 25
},
"end": {
"line": 30,
"column": 5
}
}
},
"range": [
618,
733
],
"loc": {
"start": {
"line": 26,
"column": 10
},
"end": {
"line": 30,
"column": 5
}
}
}
],
"kind": "const",
"range": [
612,
734
],
"loc": {
"start": {
"line": 26,
"column": 4
},
"end": {
"line": 30,
"column": 6
}
}
},
{
"type": "ExpressionStatement",
"expression": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "target",
"range": [
739,
745
],
"loc": {
"start": {
"line": 31,
"column": 4
},
"end": {
"line": 31,
"column": 10
}
}
},
"property": {
"type": "Identifier",
"name": "addEventListener",
"range": [
746,
762
],
"loc": {
"start": {
"line": 31,
"column": 11
},
"end": {
"line": 31,
"column": 27
}
}
},
"range": [
739,
762
],
"loc": {
"start": {
"line": 31,
"column": 4
},
"end": {
"line": 31,
"column": 27
}
}
},
"arguments": [
{
"type": "Identifier",
"name": "eventName",
"range": [
763,
772
],
"loc": {
"start": {
"line": 31,
"column": 28
},
"end": {
"line": 31,
"column": 37
}
}
},
{
"type": "Identifier",
"name": "onceListener",
"range": [
774,
786
],
"loc": {
"start": {
"line": 31,
"column": 39
},
"end": {
"line": 31,
"column": 51
}
}
}
],
"range": [
739,
787
],
"loc": {
"start": {
"line": 31,
"column": 4
},
"end": {
"line": 31,
"column": 52
}
}
},
"range": [
739,
788
],
"loc": {
"start": {
"line": 31,
"column": 4
},
"end": {
"line": 31,
"column": 53
}
}
}
],
"range": [
606,
792
],
"loc": {
"start": {
"line": 25,
"column": 34
},
"end": {
"line": 32,
"column": 3
}
}
},
"generator": false,
"expression": false,
"range": [
593,
792
],
"loc": {
"start": {
"line": 25,
"column": 21
},
"end": {
"line": 32,
"column": 3
}
}
}
],
"range": [
581,
793
],
"loc": {
"start": {
"line": 25,
"column": 9
},
"end": {
"line": 32,
"column": 4
}
}
},
"range": [
574,
794
],
"loc": {
"start": {
"line": 25,
"column": 2
},
"end": {
"line": 32,
"column": 5
}
}
}
],
"range": [
570,
796
],
"loc": {
"start": {
"line": 24,
"column": 48
},
"end": {
"line": 33,
"column": 1
}
}
},
"generator": false,
"expression": false,
"range": [
529,
796
],
"loc": {
"start": {
"line": 24,
"column": 7
},
"end": {
"line": 33,
"column": 1
}
},
"leadingComments": [
{
"type": "Block",
"value": "*\n* 指定した要素のイベントを待つプロミスを返す\n*\n* @function promiseEvent\n* @param {Element} target イベントを取得する要素\n* @param {String} eventName 取得するイベント名\n* @return {Promise<EventTarget>} deferredEvent 取得したイベント\n",
"range": [
332,
521
],
"loc": {
"start": {
"line": 16,
"column": 0
},
"end": {
"line": 23,
"column": 2
}
}
}
],
"trailingComments": [
{
"type": "Block",
"value": "*\n* 指定した大きさのcontext2dを返す\n*\n* @function createContext2d\n* @param {Number} width contextの幅\n* @param {Number} height contextの高さ\n* @param {Object} [options]\n* @param {Object} [options.pixelated=true] アンチエイリアスを切る\n* @return {CanvasRenderingContext2D}\n",
"range": [
798,
1047
],
"loc": {
"start": {
"line": 35,
"column": 0
},
"end": {
"line": 44,
"column": 2
}
}
}
]
},
"specifiers": [],
"source": null,
"range": [
522,
796
],
"loc": {
"start": {
"line": 24,
"column": 0
},
"end": {
"line": 33,
"column": 1
}
},
"leadingComments": [
{
"type": "Block",
"value": "*\n* 指定した要素のイベントを待つプロミスを返す\n*\n* @function promiseEvent\n* @param {Element} target イベントを取得する要素\n* @param {String} eventName 取得するイベント名\n* @return {Promise<EventTarget>} deferredEvent 取得したイベント\n",
"range": [
332,
521
],
"loc": {
"start": {
"line": 16,
"column": 0
},
"end": {
"line": 23,
"column": 2
}
}
}
],
"trailingComments": [
{
"type": "Block",
"value": "*\n* 指定した大きさのcontext2dを返す\n*\n* @function createContext2d\n* @param {Number} width contextの幅\n* @param {Number} height contextの高さ\n* @param {Object} [options]\n* @param {Object} [options.pixelated=true] アンチエイリアスを切る\n* @return {CanvasRenderingContext2D}\n",
"range": [
798,
1047
],
"loc": {
"start": {
"line": 35,
"column": 0
},
"end": {
"line": 44,
"column": 2
}
}
}
]
},
{
"type": "ExportNamedDeclaration",
"declaration": {
"type": "FunctionDeclaration",
"id": {
"type": "Identifier",
"name": "createContext2d",
"range": [
1064,
1079
],
"loc": {
"start": {
"line": 45,
"column": 16
},
"end": {
"line": 45,
"column": 31
}
}
},
"params": [
{
"type": "Identifier",
"name": "width",
"range": [
1080,
1085
],
"loc": {
"start": {
"line": 45,
"column": 32
},
"end": {
"line": 45,
"column": 37
}
}
},
{
"type": "Identifier",
"name": "height",
"range": [
1087,
1093
],
"loc": {
"start": {
"line": 45,
"column": 39
},
"end": {
"line": 45,
"column": 45
}
}
},
{
"type": "AssignmentPattern",
"left": {
"type": "Identifier",
"name": "options",
"range": [
1095,
1102
],
"loc": {
"start": {
"line": 45,
"column": 47
},
"end": {
"line": 45,
"column": 54
}
}
},
"right": {
"type": "ObjectExpression",
"properties": [],
"range": [
1105,
1107
],
"loc": {
"start": {
"line": 45,
"column": 57
},
"end": {
"line": 45,
"column": 59
}
}
},
"range": [
1095,
1107
],
"loc": {
"start": {
"line": 45,
"column": 47
},
"end": {
"line": 45,
"column": 59
}
}
}
],
"body": {
"type": "BlockStatement",
"body": [
{
"type": "VariableDeclaration",
"declarations": [
{
"type": "VariableDeclarator",
"id": {
"type": "Identifier",
"name": "canvas",
"range": [
1119,
1125
],
"loc": {
"start": {
"line": 46,
"column": 8
},
"end": {
"line": 46,
"column": 14
}
}
},
"init": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "document",
"range": [
1128,
1136
],
"loc": {
"start": {
"line": 46,
"column": 17
},
"end": {
"line": 46,
"column": 25
}
}
},
"property": {
"type": "Identifier",
"name": "createElement",
"range": [
1137,
1150
],
"loc": {
"start": {
"line": 46,
"column": 26
},
"end": {
"line": 46,
"column": 39
}
}
},
"range": [
1128,
1150
],
"loc": {
"start": {
"line": 46,
"column": 17
},
"end": {
"line": 46,
"column": 39
}
}
},
"arguments": [
{
"type": "Literal",
"value": "canvas",
"raw": "'canvas'",
"range": [
1151,
1159
],
"loc": {
"start": {
"line": 46,
"column": 40
},
"end": {
"line": 46,
"column": 48
}
}
}
],
"range": [
1128,
1160
],
"loc": {
"start": {
"line": 46,
"column": 17
},
"end": {
"line": 46,
"column": 49
}
}
},
"range": [
1119,
1160
],
"loc": {
"start": {
"line": 46,
"column": 8
},
"end": {
"line": 46,
"column": 49
}
}
}
],
"kind": "const",
"range": [
1113,
1161
],
"loc": {
"start": {
"line": 46,
"column": 2
},
"end": {
"line": 46,
"column": 50
}
}
},
{
"type": "ExpressionStatement",
"expression": {
"type": "AssignmentExpression",
"operator": "=",
"left": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "canvas",
"range": [
1164,
1170
],
"loc": {
"start": {
"line": 47,
"column": 2
},
"end": {
"line": 47,
"column": 8
}
}
},
"property": {
"type": "Identifier",
"name": "width",
"range": [
1171,
1176
],
"loc": {
"start": {
"line": 47,
"column": 9
},
"end": {
"line": 47,
"column": 14
}
}
},
"range": [
1164,
1176
],
"loc": {
"start": {
"line": 47,
"column": 2
},
"end": {
"line": 47,
"column": 14
}
}
},
"right": {
"type": "Identifier",
"name": "width",
"range": [
1179,
1184
],
"loc": {
"start": {
"line": 47,
"column": 17
},
"end": {
"line": 47,
"column": 22
}
}
},
"range": [
1164,
1184
],
"loc": {
"start": {
"line": 47,
"column": 2
},
"end": {
"line": 47,
"column":