1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4
<title>sim only test</title>
6
<!-- Source File and Seed for YUI3-->
7
<link rel="stylesheet" type="text/css" href="../../../../build/cssreset/reset-min.css">
8
<link type="text/css" rel="stylesheet" href="../../../../build/cssfonts/fonts-min.css">
10
<script src="../../../../build/yui/yui.js"></script>
20
background-color:#eee;
21
border:solid 1px #aaa;
31
border:solid 1px #f00;
39
border:solid 1px #000;
42
background-color:#8080ff;
52
<body class="yui3-skin-sam">
55
Click anywhere in the gray rect. to move A to the place you clicked. This is a native event.
57
<div class="end-here">B</div>
58
<div class="thing">A</div>
61
<div class="btn-container">
62
This button should <button class=sim-md>Simulate</button> a click in the gray rectangle that would place A in B.
63
<p> There seems to be a problem in IE9 with e.pageX, e.pageY in an event that receives a simulated event...</p>
67
<script type="text/javascript">
68
YUI({filter:'raw'}).use('node','node-event-simulate','event-move', function(Y) { //, filter:'raw' this make it really hard to clear cache on iPad
72
var obj = Y.one('obj'),
73
eventX = 330, //Set the X for event simulation.
74
eventY = 340; //Set the Y for event simulation.
79
var handleSimMd = function(e){
80
var scrollT = Y.one('document').get('scrollTop'),
81
scrollL = Y.one('document').get('scrollLeft');
82
Y.one('.obj').simulate("click", {clientX: eventX, clientY: eventY});
84
//Y.one('.obj').simulate("click", {clientX: (eventX - scrollL), clientY: (eventY - scrollT)}); // same as line above, only handles scrolled page
86
/* this also does not dispatch an event object that contains e.pageX/Y in IE9
87
Y.one('.obj').simulate("click", {
96
// a click (or simulated click) is handled by handleObjEvent
97
var handleObjEvent = function(e){
98
Y.one('.thing').setXY([(e.pageX),(e.pageY)]);
100
// native event the e.pageX and e.pageY have valid values, but,
101
// simulated event the e.pageX and e.pageY == 0
102
// e.clientX, and e.clientY have valid values in native events and simulated events.
104
// this will work in both simulated and native
105
//Y.one('.thing').setXY([(e.clientX),(e.clientY)]);
106
// Changing Dial.js to use e.clientX/Y, seems too risky, post test-fest
111
// a click on the button goes to handler that simulates a click on the .obj
112
Y.on('click', handleSimMd, '.sim-md');
114
// a click (or simulated click) is handled by handleObjEvent
115
Y.on('click', handleObjEvent, '.obj');
b'\\ No newline at end of file'