Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1191f29
commit 0ca898d
Showing
4 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,31 @@ | |||
@Ohm = {} if !('Ohm' of @) | |||
|
|||
Ohm.infinitePage = ($x,url) -> | |||
|
|||
s = "scroll" | |||
$w = $ window | |||
|
|||
f = () -> | |||
if $x.is(":visible") | |||
|
|||
dt = $w.scrollTop() | |||
db = dt + $w.height() | |||
et = here.$point.offset().top | |||
eb = et + here.$point.height() | |||
|
|||
if (et <= db && eb >= dt) | |||
$w.unbind s, f | |||
Ohm.post url, null, (d) -> | |||
if d.more | |||
$x.before(d.more.html) | |||
call d.more.code | |||
call d.code | |||
$x.remove() | |||
|
|||
else | |||
$w.unbind s, f | |||
|
|||
$w.bind s, f | |||
|
|||
do onScroll | |||
|
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,4 @@ | |||
<div class="ohm-ajax-infinite-page" {$t}></div> | |||
<script type="url:json"> | |||
Ohm.infinitePage here.$t, url | |||
</script> |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,16 @@ | |||
(* Ohm is © 2013 Victor Nicollet *) | |||
|
|||
open Ohm | |||
open Ohm.Universal | |||
|
|||
let of_endpoint endpoint = | |||
let json = JsCode.Endpoint.to_json endpoint in | |||
Asset_OhmInfiniteScroll_Trigger.render (object | |||
method url = json | |||
end) | |||
|
|||
let of_url url = | |||
of_endpoint (JsCode.Endpoint.of_url url) | |||
|
|||
let respond writer res = | |||
Action.json [ "more", Html.to_json writer ] res |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,6 @@ | |||
(* Ohm is © 2013 Victor Nicollet *) | |||
|
|||
val of_url : string -> ('a, Ohm.Html.writer) Ohm.Run.t | |||
val of_endpoint : Ohm.JsCode.Endpoint.t -> ('a, Ohm.Html.writer) Ohm.Run.t | |||
|
|||
val respond : Ohm.Html.writer -> Ohm.Action.response -> Ohm.Action.response |