Skip to content

Instantly share code, notes, and snippets.

@garris
Last active August 29, 2015 14:27
Show Gist options
  • Save garris/afebec8e31f5a193aa1b to your computer and use it in GitHub Desktop.
Save garris/afebec8e31f5a193aa1b to your computer and use it in GitHub Desktop.
tremula local data example
Modify `./boilerplate/index.html`
Look at line 81 where we initialize tremulajs...
```
$(document).ready(function(){
setTimeout(function(){
window.tremula = tremulaInit();//does not need to be on the window -- implemented here for convienience.
loadFlickr(); // <=== replace this line with the block below...
},1000);
});
```
replace line 81 with this...
```
var data = [
{"id":"14770557605","owner":"77358520@N00","secret":"87c851194c","server":"5591","farm":6,"title":"Paris","ispublic":1,"isfriend":0,"isfamily":0,"url_n":"https://farm6.staticflickr.com/5591/14770557605_87c851194c_n.jpg","height_n":"320","width_n":212},
{"id":"14770224262","owner":"77358520@N00","secret":"398cbf9839","server":"3858","farm":4,"title":"Paris","ispublic":1,"isfriend":0,"isfamily":0,"url_n":"https://farm4.staticflickr.com/3858/14770224262_398cbf9839_n.jpg","height_n":"320","width_n":240},
{"id":"14770557605","owner":"77358520@N00","secret":"87c851194c","server":"5591","farm":6,"title":"Paris","ispublic":1,"isfriend":0,"isfamily":0,"url_n":"https://farm6.staticflickr.com/5591/14770557605_87c851194c_n.jpg","height_n":"320","width_n":212},
{"id":"14770224262","owner":"77358520@N00","secret":"398cbf9839","server":"3858","farm":4,"title":"Paris","ispublic":1,"isfriend":0,"isfamily":0,"url_n":"https://farm4.staticflickr.com/3858/14770224262_398cbf9839_n.jpg","height_n":"320","width_n":240},
{"id":"14768250614","owner":"77358520@N00","secret":"dfa428e6ec","server":"3862","farm":4,"title":"Paris","ispublic":1,"isfriend":0,"isfamily":0,"url_n":"https://farm4.staticflickr.com/3862/14768250614_dfa428e6ec_n.jpg","height_n":212,"width_n":"320"}
];
function dataAdapter(data,env){
this.data = data;
this.w = this.width = data.width_n;
this.h = this.height = data.height_n;
this.imgUrl = data.url_n;
this.auxClassList = "flickrRS";//stamp each mapped item with map ID
this.template = this.data.template||('<img draggable="false" onload="imageLoaded(this)" class="moneyShot" src=""/>');
}
tremula.appendData(data,dataAdapter);
tremula.cache.endOfScrollFlag = false;
```
`data` is now very local. The tremulajs component will use that to populate when it bootstraps.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment