This repository has been archived by the owner on Feb 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cancel click events if dragging using "dragThreshold"
- Loading branch information
Nicolai Mortensen
committed
Aug 8, 2017
1 parent
4d2409b
commit c963103
Showing
7 changed files
with
108 additions
and
21 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style> | ||
body, html { margin: 0; padding: 0; width: 100%; height: 100%; } | ||
canvas { width: 100% !important; height: 100% !important; position: fixed; } | ||
</style> | ||
<script src="pixi.js"></script> | ||
<script src="../bin/pixi-ui.js"></script> | ||
<title></title> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height" /> | ||
|
||
</head> | ||
<body> | ||
<script type="text/javascript"> | ||
PIXI.settings.SCALE_MODE = PIXI.SCALE_MODES.LINEAR; | ||
PIXI.settings.RESOLUTION = devicePixelRatio || 1; | ||
var renderer = new PIXI.WebGLRenderer(window.innerWidth, window.innerHeight, { resolution: devicePixelRatio || 1, transparent: true }); | ||
var stage = new PIXI.Container(); | ||
var uiStage = new PIXI.UI.Stage(window.innerWidth, window.innerHeight); | ||
uiStage.minHeight = 315; | ||
uiStage.minWidth = 500; | ||
|
||
var dragContainer = new PIXI.UI.Container(); | ||
document.body.appendChild(renderer.view); | ||
stage.addChild(uiStage); | ||
var resizeFunction = function () { | ||
renderer.resize(window.innerWidth, window.innerHeight); | ||
uiStage.resize(window.innerWidth, window.innerHeight); | ||
} | ||
window.addEventListener("resize", resizeFunction); | ||
resizeFunction(); | ||
PIXI.loader.add('UISprites.json').load(function () { | ||
init(); | ||
}); | ||
|
||
|
||
function init() { | ||
var cb1_bg = PIXI.Texture.fromFrame("UI/cb-1-bg.png"); | ||
var cb1_mark = PIXI.Texture.fromFrame("UI/cb-1-mark.png"); | ||
var cb2_bg = PIXI.Texture.fromFrame("UI/cb-2-bg.png"); | ||
var cb2_mark = PIXI.Texture.fromFrame("UI/cb-2-mark.png"); | ||
|
||
var whiteBG = PIXI.Texture.fromFrame("UI/ui-box-1.png"); | ||
var innerBG = PIXI.Texture.fromFrame("UI/ui-box-2.png"); | ||
var solidBox = PIXI.Texture.fromFrame("UI/solid-box.png"); | ||
var lineSprite = PIXI.Texture.fromFrame("UI/ui-horizontal-line-border.png"); | ||
var textStyle = { fill: '#000000', fontSize: 18, fontFamily: 'Lucida Sans Typewriter' }; | ||
|
||
|
||
button = new PIXI.UI.Button({ | ||
background: new PIXI.UI.SliceSprite(PIXI.Texture.fromFrame("UI/cb-1-bg.png"), 10), | ||
}); | ||
|
||
button.on("hover", function (isHover) { | ||
console.log("hover", isHover); | ||
PIXI.UI.Tween.to(button, 0.1, { width: isHover ? 100 : 50 }); | ||
}); | ||
|
||
uiStage.addChild(button); | ||
|
||
Update(); | ||
} | ||
|
||
function Update() { | ||
renderer.render(stage); | ||
requestAnimationFrame(Update); | ||
} | ||
|
||
</script> | ||
</body> | ||
</html> |