41 lines
1.5 KiB
JSON
41 lines
1.5 KiB
JSON
{
|
|
"source": "JSON",
|
|
"data": "BLOCK",
|
|
"version": "0.0.1",
|
|
"type": "javascript.input devices.orientationchange",
|
|
"language": "javascript",
|
|
"extension": "webaudio",
|
|
"help": "Orientation Change",
|
|
"label": "Orientation Change",
|
|
"color": "#4283FA",
|
|
"group": "Input Device",
|
|
"codes": [
|
|
{
|
|
"name": "onload",
|
|
"code": "\nwindow.addEventListener('orientationchange', onOrientationChange$id$, false);\n "
|
|
},
|
|
{
|
|
"name": "declaration",
|
|
"code": "\nvar $port[portrait]$ = [];\nvar $port[landscape]$ = [];\n\nfunction onOrientationChange$id$(event){\n var isPortrait = window.orientation % 180 === 0;\n if (window.orientation % 180 === 0) {\n for (var i = 0 ; i < $port[portrait]$.length ; i++)\n $port[portrait]$[i](isPortrait);\n \n } else { \n for (var i = 0 ; i < $port[landscape]$.length ; i++)\n $port[landscape]$[i](isPortrait);\n } \n}\n"
|
|
},
|
|
{
|
|
"name": "execution",
|
|
"code": "\nonOrientationChange$id$();\n"
|
|
}
|
|
],
|
|
"properties": [],
|
|
"ports": [
|
|
{
|
|
"conn_type": "output",
|
|
"name": "portrait",
|
|
"label": "Portrait",
|
|
"type": "javascript.bool"
|
|
},
|
|
{
|
|
"conn_type": "output",
|
|
"name": "landscape",
|
|
"label": "Landscape",
|
|
"type": "javascript.bool"
|
|
}
|
|
]
|
|
} |