Skip to content

Commit

Permalink
release: v2.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
surunzi committed Aug 8, 2024
1 parent 709eb36 commit 0be8844
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 33 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v2.1.1 (8 Aug 2024)

* fix: safari not working

## v2.1.0 (7 Aug 2024)

* fix: safari not working
Expand Down
56 changes: 24 additions & 32 deletions eruda-orientation.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'.eruda-dev-tools .eruda-tools .eruda-orientation {padding: 10px; overflow-y: auto; -webkit-overflow-scrolling: touch;}',
'.eruda-not-supported {background: var(--console-error-background); color: var(--console-error-foreground); border: 1px solid var(--console-error-border);padding: 10px; text-align: center;}',
'.eruda-cube {width: 150px; height: 150px; color: var(--foreground); position: relative; margin: 50px auto; -webkit-transform-style: preserve-3d; transform-style: preserve-3d;}',
'.eruda-face {width: 150px; height: 150px; position: absolute; font-size: 80px; text-align: center; line-height: 150px; background-color: var(--accent); box-shadow: inset 0 0 20px var(--foreground); opacity: 0.6; }',
'.eruda-face {width: 150px; height: 150px; position: absolute; font-size: 80px; text-align: center; line-height: 150px; background-color: var(--accent); border: 1px solid var(--border); opacity: 0.6; }',
'.eruda-one {-webkit-transform: translateZ(75px); transform: translateZ(75px);}',
'.eruda-two {-webkit-transform: rotateY(90deg) translateZ(75px); transform: rotateY(90deg) translateZ(75px);}',
'.eruda-three {-webkit-transform: rotateY(180deg) translateZ(75px); transform: rotateY(180deg) translateZ(75px);}',
Expand Down Expand Up @@ -167,39 +167,31 @@
$interval.text(e.interval + 'ms')
}

function requestOrientationPermission() {
DeviceOrientationEvent.requestPermission().then(function (response) {
if (response === 'granted') {
window.addEventListener(
'deviceorientation',
this._onDeviceorientation
)
$cube.off('click', requestOrientationPermission)
}
})
}
if (DeviceOrientationEvent.requestPermission) {
$cube.on('click', requestOrientationPermission)
} else {
window.addEventListener(
'deviceorientation',
this._onDeviceorientation
)
}
function bind(type) {
var Event = DeviceOrientationEvent
var eventName = 'deviceorientation'
var listener = self._onDeviceorientation
if (type === 'motion') {
Event = DeviceMotionEvent
eventName = 'devicemotion'
listener = self._onDevicemotion
}

function requestMotionPermission() {
DeviceMotionEvent.requestPermission().then(function (response) {
if (response === 'granted') {
window.addEventListener('devicemotion', this._onDevicemotion)
$cube.off('click', requestMotionPermission)
}
})
}
if (DeviceMotionEvent.requestPermission) {
$cube.on('click', requestMotionPermission)
} else {
window.addEventListener('devicemotion', this._onDevicemotion)
function requestPermission() {
Event.requestPermission().then(function (response) {
if (response === 'granted') {
$cube.off('click', requestPermission)
}
})
}
if (Event.requestPermission) {
$cube.on('click', requestPermission)
}
window.addEventListener(eventName, listener)
}

bind('orientation')
bind('motion')
},
show: function () {
this.callSuper(Tool, 'show', arguments)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eruda-orientation",
"version": "2.1.0",
"version": "2.1.1",
"main": "eruda-orientation.js",
"description": "Eruda plugin for testing orientation api",
"files": [
Expand Down

0 comments on commit 0be8844

Please sign in to comment.