storys 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,22 +12,27 @@
12
12
  return;
13
13
  }
14
14
 
15
- twoup.content = content = $("<div></div>").css({ "-webkit-column-rule": column_rule, "-moz-column-rule": column_rule, "column-rule": column_rule });
16
- twoup.slider = slider = $("<div></div>");
17
- twoup.padding = padding = $(this).css({ "overflow": "hidden" });
15
+ if(twoup.enabled()) {
16
+ twoup.content = content = $("<div></div>").css({ "-webkit-column-rule": column_rule, "-moz-column-rule": column_rule, "column-rule": column_rule });
17
+ twoup.slider = slider = $("<div></div>");
18
+ twoup.padding = padding = $(this).css({ "overflow": "hidden" });
18
19
 
19
- var children = padding.children().detach();
20
- padding.append(slider);
21
- slider.append(content);
22
- content.append(children);
20
+ var children = padding.children().detach();
21
+ padding.append(slider);
22
+ slider.append(content);
23
+ content.append(children);
23
24
 
24
- if(!twoup.enabled()) return;
25
-
26
- $(window).resize(twoup.layout).resize();
25
+ $(window).resize(twoup.layout).resize();
27
26
 
28
- $(window).bind('hashchange', function() {
29
- slider.css({ "margin-left": -((twoup.page() - 1) * scroll_width) + "px" });
30
- }).trigger('hashchange');
27
+ $(window).bind('hashchange', function() {
28
+ slider.animate({ "margin-left": -((twoup.page() - 1) * scroll_width) + "px" }, 300);
29
+ }).trigger('hashchange');
30
+ }
31
+ else {
32
+ $(window).bind('hashchange', function() {
33
+ $("body").animate({ scrollTop: (twoup.page() - 1) * Math.max(0, $(window).height() - 60) }, 300);
34
+ }).trigger('hashchange');
35
+ }
31
36
 
32
37
  $(window).keydown(function(event) {
33
38
  if(event.keyCode == 32 || event.keyCode == 39) {
@@ -45,19 +50,35 @@
45
50
 
46
51
  twoup.enabled = function() {
47
52
  //at the moment, only WebKit and MSIE10 has proper support for css3 columns AND getting the right width for a column element with overflow
48
- return $.browser.webkit || ($.browser.msie && $.browser.version >= 10);
53
+ //at the moment, android and iphone scale the output weirdly, and their CPU can't really handle the multicolums on large pages
54
+ return ($.browser.webkit || ($.browser.msie && $.browser.version >= 10)) && (!$.browser.android && !$.browser.iphone);
49
55
  }
50
56
 
51
57
  twoup.columns = function() {
52
- return Math.max(1, Math.floor($(window).width() / (18 * padding_width)));
58
+ if(twoup.enabled()) {
59
+ return Math.max(1, Math.floor($(window).width() / (18 * padding_width)));
60
+ }
61
+ else {
62
+ return 1;
63
+ }
53
64
  };
54
65
 
55
66
  twoup.column_width = function() {
56
- return twoup.enabled() ? parseInt(content.css("-webkit-column-width") || content.css("-moz-column-width") || content.css("column-width")) : content.width()
67
+ if(twoup.enabled()) {
68
+ return parseInt(content.css("-webkit-column-width") || content.css("-moz-column-width") || content.css("column-width"));
69
+ }
70
+ else {
71
+ return content.width();
72
+ }
57
73
  };
58
74
 
59
75
  twoup.pages = function() {
60
- return Math.ceil(content_width / scroll_width);
76
+ if(twoup.enabled()) {
77
+ return Math.ceil(content_width / scroll_width);
78
+ }
79
+ else {
80
+ return Math.ceil($(document).height() / ($(window).height() - 60));
81
+ }
61
82
  };
62
83
 
63
84
  twoup.bound_page_number = function(number) {
@@ -81,18 +102,22 @@
81
102
  };
82
103
 
83
104
  twoup.layout = function() {
105
+ if(!twoup.enabled()) return;
106
+
84
107
  padding_width = parseInt(padding.css("padding-top"));
85
108
 
86
109
  var old_columns = columns;
87
110
  columns = twoup.columns();
88
111
 
89
112
  var column_gap_width = (padding_width * 2) + parseInt(content.css("-webkit-column-rule-width") || content.css("column-rule-width"));
90
- var inner_width = window.innerWidth - (padding_width * 2);
91
- var inner_height = window.innerHeight - (padding_width * 2);
113
+ var wrapper_width = window.innerWidth;
114
+ var wrapper_height = window.innerHeight;
115
+ var inner_width = wrapper_width - (padding_width * 2);
116
+ var inner_height = wrapper_height - (padding_width * 2);
92
117
  var column_width = Math.floor((inner_width - (column_gap_width * (columns - 1))) / columns);
93
118
  scroll_width = inner_width + column_gap_width;
94
119
 
95
- padding.css({ "width": inner_width + "px", "height": inner_height + "px", "overflow": "hidden" });
120
+ padding.css({ "width": wrapper_width + "px", "height": wrapper_height + "px", "overflow": "hidden" });
96
121
  content.css({ "width": inner_width + "px", "height": inner_height + "px", "-webkit-column-width": column_width + "px",
97
122
  "-moz-column-width": column_width + "px", "column-width": column_width + "px", "-webkit-column-gap": column_gap_width + "px",
98
123
  "-moz-column-gap": column_gap_width + "px", "column-gap": column_gap_width + "px" });