Instantly share code, notes, and snippets.

@tnajdek /.slate.js
Last active Oct 18, 2018

Embed
What would you like to do?
My basic slate file
var moveops = [];
for(let j = 1; j < 5; j++) {
moveops[j] = [];
for(let i = 0; i < j; i++) {
moveops[j][i] = [];
for(let k = 0; k < 5; k++) {
let f = win => {
let op = slate.operation("move", {
x: `screenOriginX + ${i} * (screenSizeX/${j})`,
y: "screenOriginY",
width: `(screenSizeX/${j}) * ${k}`,
height: "screenSizeY"
});
win && win.doOperation(op)
};
moveops[j][i].push(f);
}
}
}
let screenNext = win => {
if(!win) {
return;
}
var screenCount = slate.screenCount(),
curScreenId = parseInt(win.screen().id()),
targetScreen;
if(curScreenId + 1 >= screenCount) {
targetScreen = slate.screenForRef("0")
} else {
targetScreen = slate.screenForRef(`${curScreenId + 1}`)
}
slate.log(`current screen ${curScreenId}; target screen ${targetScreen.id()}; screen count: ${screenCount}`);
let op = slate.operation("throw", {
screen: targetScreen
});
win && win.doOperation(op);
};
let screenPrev = win => {
if(!win) {
return;
}
var screenCount = slate.screenCount(),
curScreenId = parseInt(win.screen().id()),
targetScreen;
if(curScreenId == 0) {
targetScreen = slate.screenForRef(`${screenCount - 1}`);
} else {
targetScreen = slate.screenForRef(`${curScreenId - 1}`);
}
slate.log(`current screen ${curScreenId}; target screen ${targetScreen.id()}; screen count: ${screenCount}`);
let op = slate.operation("throw", {
screen: targetScreen
});
win && win.doOperation(op);
};
slate.bind("up:ctrl,alt", screenNext);
slate.bind("down:ctrl,alt", screenPrev);
slate.bind("m:ctrl,alt", moveops[4][0][1]);
slate.bind(",:ctrl,alt", moveops[4][1][1]);
slate.bind(".:ctrl,alt", moveops[4][2][1]);
slate.bind("/:ctrl,alt", moveops[4][3][1]);
slate.bind("l:ctrl,alt", moveops[3][0][1]);
slate.bind(";:ctrl,alt", moveops[3][1][1]);
slate.bind("':ctrl,alt", moveops[3][2][1]);
slate.bind("l:2,ctrl,alt", moveops[3][0][2]);
slate.bind(";:2,ctrl,alt", moveops[3][1][2]);
slate.bind("[:ctrl,alt", moveops[2][0][1]);
slate.bind("]:ctrl,alt", moveops[2][1][1]);
slate.bind("backslash:ctrl,alt", moveops[1][0][1]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment