-
Notifications
You must be signed in to change notification settings - Fork 19
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
Showing
3 changed files
with
89 additions
and
4 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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Ractive - Declarative, Model-driven Documents | ||
|
||
|
||
## The Naive Approach | ||
|
||
Too many javascript applications contain repetitive code. First, you select a an element using its ID, `var myNode = $('#something-to-use')` then update its content `myNode.html('<p>add this content to the node.</p>')`; and repeat this until everything is up to date. | ||
|
||
I love jQuery, but this is bad practice. Too many lines of code and searching by css selectors will slow down your code. | ||
|
||
## The JS Framework approach | ||
|
||
There are plenty of shiny new javascript frameworks to help you be organized and efficient while writing code: | ||
|
||
[ToDoMVC - JS Frameworks listing](http://todomvc.com/) | ||
|
||
These frameworks provide methods for ajax requests, templating, code-compiling, testing, data-binding, and much more. | ||
|
||
## The Ractive Approach | ||
|
||
Ractive does one thing and it does one thing wonderfully. Binding a JSON data object to an HTML model. Take a quick look at this sample code. | ||
|
||
#### HTML | ||
|
||
<script src='http://cdn.ractivejs.org/latest/ractive.min.js'></script> | ||
|
||
<script id='template' type='text/ractive'> | ||
<h1>{{title}}</h1> | ||
<p>{{x}} * {{y}} == {{ x * y }}!</p> | ||
</script> | ||
|
||
<div id='container'>Attempting to load template...</div> | ||
|
||
|
||
#### Javascript | ||
|
||
ractive = new Ractive({ | ||
el: 'container', | ||
template: '<p>{{greeting}}, {{recipient}}!</p>', | ||
data: { x: 5, y:6 , title: 'Multiplying Numbers'} | ||
}); |
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 | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,48 @@ | ||
# [Instagram Infinite Scroll](https://github.com/DDKnoll/Instagram-Infinite-Scroll) | ||
# [Instagram Infinite Scroll](http://ddknoll.github.io/Instagram-Infinite-Scroll/) | ||
|
||
In progress... Functional, but not yet documented. | ||
[Demo](http://ddknoll.github.io/Instagram-Infinite-Scroll/) | ||
|
||
Instagram Infinite Feed | ||
|
||
Sample Usage: | ||
|
||
<script src="js/ractive/Ractive-legacy.0.3.9.min.js"></script><!-- Get Ractive--> | ||
<script src="js/instagram.js"></script> <!-- Get Instagram extension --> | ||
<script id='template' type='text/ractive' src='templates/twitter-feed.rac'></script> | ||
|
||
|
||
/** This code is just for the infinite scroll. You don't have to use this. */ | ||
var infiniteScrollBinding = function(){ | ||
//Infinite Scroll Window Bindings | ||
$(window).scroll(function(evt){ | ||
var bod = $('body')[0]; | ||
pageHeight = bod.offsetHeight; | ||
bottomScroll = window.scrollY + bod.clientHeight; | ||
if(pageHeight - bottomScroll < 200){ | ||
insta.load('after'); | ||
} | ||
}); | ||
} | ||
|
||
//Create New Instagram Feed | ||
insta = new instagramFeed({ | ||
el: 'template-target', | ||
template: template, | ||
clientID: 'Your Instagram Client ID', | ||
hashtag: 'webdesign', | ||
complete: infiniteScrollBinding | ||
}); | ||
|
||
Function Reference | ||
|
||
insta.load('replace'); // Replace the current data (Reload) | ||
insta.load('before'); // Check for newer posts | ||
insta.load('after'); // Load Older Posts | ||
insta.set('search', 'yolo'); //Set Value of Search | ||
insta.get() //Inspect the Data | ||
|
||
|
||
TODO: | ||
|
||
1. Minify JS | ||
2. Finish Documentation |
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