Skip to content

Commit

Permalink
fixed mousewheel & wheel
Browse files Browse the repository at this point in the history
  • Loading branch information
akira-cn committed Sep 30, 2020
1 parent eea14fe commit 59a2883
Show file tree
Hide file tree
Showing 24 changed files with 115 additions and 24 deletions.
6 changes: 4 additions & 2 deletions dist/spritejs.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ const helpers = {
let spriteVer;

if (true) {
spriteVer = "3.7.26"; // eslint-disable-line no-undef
spriteVer = "3.7.27"; // eslint-disable-line no-undef
} else {}

const version = spriteVer;
Expand Down Expand Up @@ -19353,6 +19353,7 @@ class Node {
}

addEventListener(type, listener, options = {}) {
if (type === 'mousewheel') type = 'wheel';
if (typeof options === 'boolean') options = {
capture: options
};
Expand Down Expand Up @@ -19482,7 +19483,8 @@ class Node {
}

event.target = this;
const type = event.type;
let type = event.type;
if (type === 'mousewheel') type = 'wheel';
const elements = [this];
let parent = this.parent;

Expand Down
2 changes: 1 addition & 1 deletion dist/spritejs.es.min.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions dist/spritejs.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ const helpers = {
let spriteVer;

if (true) {
spriteVer = "3.7.26"; // eslint-disable-line no-undef
spriteVer = "3.7.27"; // eslint-disable-line no-undef
} else {}

const version = spriteVer;
Expand Down Expand Up @@ -19344,6 +19344,7 @@ class Node {
}

addEventListener(type, listener, options = {}) {
if (type === 'mousewheel') type = 'wheel';
if (typeof options === 'boolean') options = {
capture: options
};
Expand Down Expand Up @@ -19473,7 +19474,8 @@ class Node {
}

event.target = this;
const type = event.type;
let type = event.type;
if (type === 'mousewheel') type = 'wheel';
const elements = [this];
let parent = this.parent;

Expand Down
4 changes: 3 additions & 1 deletion dist/spritejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ var helpers = {
var spriteVer;

if (true) {
spriteVer = "3.7.26"; // eslint-disable-line no-undef
spriteVer = "3.7.27"; // eslint-disable-line no-undef
} else {}

var version = spriteVer;
Expand Down Expand Up @@ -21504,6 +21504,7 @@ var Node = /*#__PURE__*/function () {
key: "addEventListener",
value: function addEventListener(type, listener) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
if (type === 'mousewheel') type = 'wheel';
if (typeof options === 'boolean') options = {
capture: options
};
Expand Down Expand Up @@ -21650,6 +21651,7 @@ var Node = /*#__PURE__*/function () {

event.target = this;
var type = event.type;
if (type === 'mousewheel') type = 'wheel';
var elements = [this];
var parent = this.parent;

Expand Down
2 changes: 1 addition & 1 deletion dist/spritejs.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion dist/spritejs.worker.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -19214,6 +19214,7 @@ class Node {
}

addEventListener(type, listener, options = {}) {
if (type === 'mousewheel') type = 'wheel';
if (typeof options === 'boolean') options = {
capture: options
};
Expand Down Expand Up @@ -19343,7 +19344,8 @@ class Node {
}

event.target = this;
const type = event.type;
let type = event.type;
if (type === 'mousewheel') type = 'wheel';
const elements = [this];
let parent = this.parent;

Expand Down
2 changes: 1 addition & 1 deletion dist/spritejs.worker.es.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion dist/spritejs.worker.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -19205,6 +19205,7 @@ class Node {
}

addEventListener(type, listener, options = {}) {
if (type === 'mousewheel') type = 'wheel';
if (typeof options === 'boolean') options = {
capture: options
};
Expand Down Expand Up @@ -19334,7 +19335,8 @@ class Node {
}

event.target = this;
const type = event.type;
let type = event.type;
if (type === 'mousewheel') type = 'wheel';
const elements = [this];
let parent = this.parent;

Expand Down
2 changes: 2 additions & 0 deletions dist/spritejs.worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -21365,6 +21365,7 @@ var Node = /*#__PURE__*/function () {
key: "addEventListener",
value: function addEventListener(type, listener) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
if (type === 'mousewheel') type = 'wheel';
if (typeof options === 'boolean') options = {
capture: options
};
Expand Down Expand Up @@ -21511,6 +21512,7 @@ var Node = /*#__PURE__*/function () {

event.target = this;
var type = event.type;
if (type === 'mousewheel') type = 'wheel';
var elements = [this];
var parent = this.parent;

Expand Down
2 changes: 1 addition & 1 deletion dist/spritejs.worker.min.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions docs/demo/spritejs.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ const helpers = {
let spriteVer;

if (true) {
spriteVer = "3.7.26"; // eslint-disable-line no-undef
spriteVer = "3.7.27"; // eslint-disable-line no-undef
} else {}

const version = spriteVer;
Expand Down Expand Up @@ -19353,6 +19353,7 @@ class Node {
}

addEventListener(type, listener, options = {}) {
if (type === 'mousewheel') type = 'wheel';
if (typeof options === 'boolean') options = {
capture: options
};
Expand Down Expand Up @@ -19482,7 +19483,8 @@ class Node {
}

event.target = this;
const type = event.type;
let type = event.type;
if (type === 'mousewheel') type = 'wheel';
const elements = [this];
let parent = this.parent;

Expand Down
2 changes: 1 addition & 1 deletion docs/demo/spritejs.es.min.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions docs/demo/spritejs.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ const helpers = {
let spriteVer;

if (true) {
spriteVer = "3.7.26"; // eslint-disable-line no-undef
spriteVer = "3.7.27"; // eslint-disable-line no-undef
} else {}

const version = spriteVer;
Expand Down Expand Up @@ -19344,6 +19344,7 @@ class Node {
}

addEventListener(type, listener, options = {}) {
if (type === 'mousewheel') type = 'wheel';
if (typeof options === 'boolean') options = {
capture: options
};
Expand Down Expand Up @@ -19473,7 +19474,8 @@ class Node {
}

event.target = this;
const type = event.type;
let type = event.type;
if (type === 'mousewheel') type = 'wheel';
const elements = [this];
let parent = this.parent;

Expand Down
4 changes: 3 additions & 1 deletion docs/demo/spritejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ var helpers = {
var spriteVer;

if (true) {
spriteVer = "3.7.26"; // eslint-disable-line no-undef
spriteVer = "3.7.27"; // eslint-disable-line no-undef
} else {}

var version = spriteVer;
Expand Down Expand Up @@ -21504,6 +21504,7 @@ var Node = /*#__PURE__*/function () {
key: "addEventListener",
value: function addEventListener(type, listener) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
if (type === 'mousewheel') type = 'wheel';
if (typeof options === 'boolean') options = {
capture: options
};
Expand Down Expand Up @@ -21650,6 +21651,7 @@ var Node = /*#__PURE__*/function () {

event.target = this;
var type = event.type;
if (type === 'mousewheel') type = 'wheel';
var elements = [this];
var parent = this.parent;

Expand Down
2 changes: 1 addition & 1 deletion docs/demo/spritejs.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion docs/demo/spritejs.worker.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -19214,6 +19214,7 @@ class Node {
}

addEventListener(type, listener, options = {}) {
if (type === 'mousewheel') type = 'wheel';
if (typeof options === 'boolean') options = {
capture: options
};
Expand Down Expand Up @@ -19343,7 +19344,8 @@ class Node {
}

event.target = this;
const type = event.type;
let type = event.type;
if (type === 'mousewheel') type = 'wheel';
const elements = [this];
let parent = this.parent;

Expand Down
2 changes: 1 addition & 1 deletion docs/demo/spritejs.worker.es.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion docs/demo/spritejs.worker.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -19205,6 +19205,7 @@ class Node {
}

addEventListener(type, listener, options = {}) {
if (type === 'mousewheel') type = 'wheel';
if (typeof options === 'boolean') options = {
capture: options
};
Expand Down Expand Up @@ -19334,7 +19335,8 @@ class Node {
}

event.target = this;
const type = event.type;
let type = event.type;
if (type === 'mousewheel') type = 'wheel';
const elements = [this];
let parent = this.parent;

Expand Down
2 changes: 2 additions & 0 deletions docs/demo/spritejs.worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -21365,6 +21365,7 @@ var Node = /*#__PURE__*/function () {
key: "addEventListener",
value: function addEventListener(type, listener) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
if (type === 'mousewheel') type = 'wheel';
if (typeof options === 'boolean') options = {
capture: options
};
Expand Down Expand Up @@ -21511,6 +21512,7 @@ var Node = /*#__PURE__*/function () {

event.target = this;
var type = event.type;
if (type === 'mousewheel') type = 'wheel';
var elements = [this];
var parent = this.parent;

Expand Down
2 changes: 1 addition & 1 deletion docs/demo/spritejs.worker.min.js

Large diffs are not rendered by default.

63 changes: 63 additions & 0 deletions examples/bug_mousewheel.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="/js/spritejs.js"></script>
<style>
#container {
position: absolute;
width: 600px;
height: 600px;
}
</style>
</head>
<body>
<div id="container"></div>
<script>
const {Scene, Group, Sprite} = spritejs;
const textureURL = 'https://p4.ssl.qhimg.com/t012170360e1552ce17.png';
const container = document.getElementById('container');
const scene = new Scene({
container,
displayRatio: 2,
width: 600,
height: 600,
});

const fglayer = scene.layer('fglayer');
const g = new Group();
g.attr({
size: [2000, 2000],
anchor: 0.5,
pos: [300, 300],
scale: [1, -1],
bgcolor: 'rgba(255, 255, 0, 0.2)',
});
const el = new Sprite();
el.attr({
anchor: 0.5,
borderWidth: 0,
borderColor: 'rgba(0,0,0,1)',
bgcolor: 'red',
transformOrigin: [50, 50],
texture: textureURL,
});
g.append(el);
fglayer.appendChild(g);

let o = 1;
g.addEventListener('mousewheel', (e) => {
const delta = e.originalEvent.wheelDeltaY > 0 ? 0.1 : -0.1;

o += delta;
o = Math.min(1, Math.max(0, o));
e.target.attr({
opacity: o,
});
});
</script>
</body>
</html>
2 changes: 2 additions & 0 deletions lib/node/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ var Node = /*#__PURE__*/function () {
key: "addEventListener",
value: function addEventListener(type, listener) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
if (type === 'mousewheel') type = 'wheel';
if (typeof options === 'boolean') options = {
capture: options
};
Expand Down Expand Up @@ -251,6 +252,7 @@ var Node = /*#__PURE__*/function () {

event.target = this;
var type = event.type;
if (type === 'mousewheel') type = 'wheel';
var elements = [this];
var parent = this.parent;

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": "spritejs",
"version": "3.7.26",
"version": "3.7.27",
"description": "A cross platform high-performance graphics system.",
"main": "dist/spritejs.js",
"typings": "typings/spritejs.d.ts",
Expand Down
4 changes: 3 additions & 1 deletion src/node/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ export default class Node {
}

addEventListener(type, listener, options = {}) {
if(type === 'mousewheel') type = 'wheel';
if(typeof options === 'boolean') options = {capture: options};
const {capture, once} = options;
const eventListeners = capture ? _captureEventListeners : _eventListeners;
Expand Down Expand Up @@ -294,7 +295,8 @@ export default class Node {
event = new SpriteEvent(event);
}
event.target = this;
const type = event.type;
let type = event.type;
if(type === 'mousewheel') type = 'wheel';

const elements = [this];
let parent = this.parent;
Expand Down

0 comments on commit 59a2883

Please sign in to comment.