mirror of
https://github.com/apache/cordova-plugin-screen-orientation.git
synced 2025-05-05 01:32:59 +08:00
update look and feel of demo, add/remove event listeners
This commit is contained in:
parent
fc2df8bec1
commit
90128f42d7
@ -41,22 +41,13 @@ body {
|
|||||||
height:100%;
|
height:100%;
|
||||||
margin:0px;
|
margin:0px;
|
||||||
padding:0px;
|
padding:0px;
|
||||||
text-transform:uppercase;
|
padding-top:20px;
|
||||||
width:100%;
|
width:100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Portrait layout (default) */
|
/* Portrait layout (default) */
|
||||||
.app {
|
.app {
|
||||||
background:url(../img/logo.png) no-repeat center top; /* 170px x 200px */
|
|
||||||
position:absolute; /* position in the center of the screen */
|
|
||||||
left:50%;
|
|
||||||
top:50%;
|
|
||||||
height:50px; /* text area height */
|
|
||||||
width:225px; /* text area width */
|
|
||||||
text-align:center;
|
text-align:center;
|
||||||
padding:180px 0px 0px 0px; /* image height is 200px (bottom 20px are overlapped with text) */
|
|
||||||
margin:-115px 0px 0px -112px; /* offset vertical: half of image height and text area height */
|
|
||||||
/* offset horizontal: half of text area width */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Landscape layout (with min-width) */
|
/* Landscape layout (with min-width) */
|
||||||
@ -69,6 +60,19 @@ body {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
border:solid 1px #946A4b;
|
||||||
|
background:#666;
|
||||||
|
color:#fff;
|
||||||
|
border-radius:4px;
|
||||||
|
-webkit-border-radius:4px;
|
||||||
|
font-size:12px;
|
||||||
|
|
||||||
|
margin:8px;
|
||||||
|
padding:6px;
|
||||||
|
width:128px;
|
||||||
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
font-size:24px;
|
font-size:24px;
|
||||||
font-weight:normal;
|
font-weight:normal;
|
||||||
@ -102,13 +106,13 @@ h1 {
|
|||||||
50% { opacity: 0.4; }
|
50% { opacity: 0.4; }
|
||||||
to { opacity: 1.0; }
|
to { opacity: 1.0; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@-webkit-keyframes fade {
|
@-webkit-keyframes fade {
|
||||||
from { opacity: 1.0; }
|
from { opacity: 1.0; }
|
||||||
50% { opacity: 0.4; }
|
50% { opacity: 0.4; }
|
||||||
to { opacity: 1.0; }
|
to { opacity: 1.0; }
|
||||||
}
|
}
|
||||||
|
|
||||||
.blink {
|
.blink {
|
||||||
animation:fade 3000ms infinite;
|
animation:fade 3000ms infinite;
|
||||||
-webkit-animation:fade 3000ms infinite;
|
-webkit-animation:fade 3000ms infinite;
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
to you under the Apache License, Version 2.0 (the
|
to you under the Apache License, Version 2.0 (the
|
||||||
"License"); you may not use this file except in compliance
|
"License"); you may not use this file except in compliance
|
||||||
with the License. You may obtain a copy of the License at
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,
|
||||||
software distributed under the License is distributed on an
|
software distributed under the License is distributed on an
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
@ -42,6 +42,7 @@
|
|||||||
<p class="event listening">Connecting to Device</p>
|
<p class="event listening">Connecting to Device</p>
|
||||||
<p class="event received">Device is Ready</p>
|
<p class="event received">Device is Ready</p>
|
||||||
</div>
|
</div>
|
||||||
|
<h4>Set screen.orientation.lock();</h4>
|
||||||
<div>
|
<div>
|
||||||
<button id="btnPortrait">Portrait</button>
|
<button id="btnPortrait">Portrait</button>
|
||||||
<button id="btnLandscape">Landscape</button>
|
<button id="btnLandscape">Landscape</button>
|
||||||
@ -50,9 +51,16 @@
|
|||||||
<button id="btnPortPrimary">Portrait - Primary</button>
|
<button id="btnPortPrimary">Portrait - Primary</button>
|
||||||
<button id="btnLandPrimary">Landscape - Primary</button>
|
<button id="btnLandPrimary">Landscape - Primary</button>
|
||||||
</div>
|
</div>
|
||||||
<button id="btnAny">Unlock</button>
|
<div>
|
||||||
<button id="btnOnchange">Onchange</button>
|
<button id="btnAny">Unlock</button>
|
||||||
<button id="btnAddEvtListener">Add Event</button>
|
<button style="opacity:0;"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h4>Listen for events</h4>
|
||||||
|
<div>
|
||||||
|
<button id="btnOnchange">assign onchange</button>
|
||||||
|
<button id="btnAddEvtListener">addEventListener</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript" src="cordova.js"></script>
|
<script type="text/javascript" src="cordova.js"></script>
|
||||||
<script type="text/javascript" src="js/index.js"></script>
|
<script type="text/javascript" src="js/index.js"></script>
|
||||||
|
@ -66,12 +66,32 @@ var app = {
|
|||||||
btnAny.addEventListener("click", function() {
|
btnAny.addEventListener("click", function() {
|
||||||
screen.orientation.unlock();
|
screen.orientation.unlock();
|
||||||
});
|
});
|
||||||
btnOnchange.addEventListener("click", function() {
|
|
||||||
screen.orientation.onchange = myFunction1();
|
|
||||||
|
|
||||||
|
var hasOnChange = false;
|
||||||
|
btnOnchange.addEventListener("click", function() {
|
||||||
|
if(hasOnChange) {
|
||||||
|
screen.orientation.onchange = undefined;
|
||||||
|
btnOnchange.innerText = "assign onchange";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
screen.orientation.onchange = myFunction1;
|
||||||
|
btnOnchange.innerText = "remove onchange";
|
||||||
|
}
|
||||||
|
hasOnChange = !hasOnChange;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var hasListener = false;
|
||||||
btnAddEvtListener.addEventListener("click", function() {
|
btnAddEvtListener.addEventListener("click", function() {
|
||||||
screen.orientation.addEventListener('change', myFunction2(), true);
|
if(hasListener) {
|
||||||
|
screen.orientation.removeEventListener('change', myFunction2);
|
||||||
|
btnAddEvtListener.innerText = "addEventListener";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
screen.orientation.addEventListener('change', myFunction2);
|
||||||
|
btnAddEvtListener.innerText = "remEventListener";
|
||||||
|
}
|
||||||
|
hasListener = !hasListener;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user