Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
import 'dart:html';
class Window {
DivElement baseWindowDiv;
DivElement baseWindowTitleDiv;
num windowX;
num windowY;
num deltaX;
num deltaY;
void init() {
baseWindowDiv = new DivElement();
baseWindowDiv.$dom_className = "base-window";
baseWindowTitleDiv = new DivElement();
baseWindowTitleDiv.$dom_className = "base-window-title";
baseWindowTitleDiv.text = "Привет Мое окошео";
baseWindowDiv.append(baseWindowTitleDiv);
baseWindowTitleDiv.on.mouseDown.add((MouseEvent event) => saveWindowXY(event));
baseWindowTitleDiv.on.mouseUp.add((MouseEvent event) => stopMoveEvent(event));
DivElement baseWindowBodyDiv = new DivElement();
baseWindowBodyDiv.$dom_className = "base-window-body";
baseWindowBodyDiv.text = "Привет Body окошка";
baseWindowDiv.append(baseWindowBodyDiv);
DivElement baseWindowResizeDiv = new DivElement();
baseWindowResizeDiv.$dom_className = "base-window-resize-div";
baseWindowDiv.append(baseWindowResizeDiv);
}
void saveWindowXY(MouseEvent event) {
num mouseX = event.pageX;
num mouseY = event.pageY;
windowX = baseWindowDiv.offsetLeft;
windowY = baseWindowDiv.offsetTop;
deltaX = windowX - mouseX;
deltaY = windowY - mouseY;
document.on.mouseMove.add((MouseEvent event) => runMoveEvent(event));
}
void stopMoveEvent(MouseEvent event) {
print('stopMoveEvent call');
document.on.mouseMove.remove((MouseEvent event) => runMoveEvent(event));//does not work!
}
void runMoveEvent(MouseEvent event) {
num x = event.pageX;
num y = event.pageY;
num newX = deltaX + x;
num newY = deltaY + y;
StringBuffer bufferStrX = new StringBuffer();
bufferStrX.add(newX.toString());
bufferStrX.add("px");
StringBuffer bufferStrY = new StringBuffer();
bufferStrY.add(newY.toString());
bufferStrY.add("px");
baseWindowDiv.style.left = bufferStrX.toString();
baseWindowDiv.style.top = bufferStrY.toString();
}
void show() {
document.body.elements.add(baseWindowDiv);
}
}
void main() {
Window w = new Window();
w.init();
w.show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.