How to add an eventlistener on a certain part of a screen using javascript
R
Rivera.migueld
started a topic
over 9 years ago
How to add an eventlistener on a certain part of a screen using javascript
1 Comment
R
Rivera.migueld
said
over 9 years ago
I was wondering if you can assign an event listener on a certain part of a mobile phone screen? For example just 90% of the screen only. I have an bottle that will spin regarding of the direction of the swipe. I have a button on the bottom of the screen that when is clicked, will go back two pages. However, when I click the button, the "click" is not triggered, instead the eventlistener is always triggered. Here is my code.Thanks.
var w = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
var firstSwipe = false;
var alreadyswiped = false;
var isSeen = false;
var World = {
loaded: false,
init: function initFn() {
/* Disable all sensors in "IR-only" Worlds to save performance. If the property is set to true, any geo-related components (such as GeoObjects and ActionRanges) are active. If the property is set to false, any geo-related components will not be visible on the screen, and triggers will not fire.*/
AR.context.services.sensors = false;
this.createOverlays();
},
createOverlays: function createOverlaysFn() {
// Initialize Tracker
// Important: If you replace the tracker file with your own, make sure to change the target name accordingly.
// e.g. replace "pageOne" used for creating the AR.Trackeable2DOBject below, with the name of one of your new target images.
this.tracker = new AR.Tracker("SpinTheBottleTarget.wtc", {
//onLoaded: this.worldLoaded
});
// Create overlay for page one
var imgOne = new AR.ImageResource("fruitsarrow.png");
var overlayOne = new AR.ImageDrawable(imgOne, 1, {
zOrder: 0,
scale: 1.55,
offsetY: -0.03,
});
var imgTwo = new AR.ImageResource("sanmigbottle.png");
var overlayTwo = new AR.ImageDrawable(imgTwo, 1, {
zOrder: 1
});
var pageOne = new AR.Trackable2DObject(this.tracker, "spinthebottle", {
drawables: {
cam:
},
onEnterFieldOfVision: function onEnterFieldOfViewFn () {
swipeFunc.init(true);
},
onExitFieldOfVision : function onExitFieldofViewFn (){
swipeFunc.init(false);
}
});
this.rotationAnimationstartRight = function rotation(){
Rivera.migueld