2Elm.Native.Window.make = function(elm) {
4 elm.Native = elm.Native || {};
5 elm.Native.Window = elm.Native.Window || {};
6 if (elm.Native.Window.values) return elm.Native.Window.values;
8 var Signal = Elm.Signal.make(elm);
9 var Tuple2 = Elm.Native.Utils.make(elm).Tuple2;
11 function getWidth() { return elm.node.clientWidth; }
12 function getHeight() {
13 if (elm.display === ElmRuntime.Display.FULLSCREEN) {
14 return window.innerHeight;
16 return elm.node.clientHeight;
19 var dimensions = Signal.constant(Tuple2(getWidth(), getHeight()));
20 dimensions.defaultNumberOfKids = 2;
22 // Do not move width and height into Elm. By setting the default number of kids,
23 // the resize listener can be detached.
24 var width = A2(Signal.lift, function(p){return p._0;}, dimensions);
25 width.defaultNumberOfKids = 0;
27 var height = A2(Signal.lift, function(p){return p._1;}, dimensions);
28 height.defaultNumberOfKids = 0;
30 function resizeIfNeeded() {
33 if (dimensions.value._0 === w && dimensions.value._1 === h) return;
34 elm.notify(dimensions.id, Tuple2(w,h));
36 elm.addListener([dimensions.id], window, 'resize', resizeIfNeeded);
38 return elm.Native.Window.values = {
39 dimensions:dimensions,
42 resizeIfNeeded:resizeIfNeeded
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list