The slide deck I used at Respond 2014. The slides where the code is brought together originally used video to show the full experience, in this slide deck there is only a single image :(
You can view the code samples prepared for this slide deck here: https://github.com/dp-lewis/respond
3. “At first I was angry, but then sadness
crept in as I realised that
I’m never going to be able to read
those m***** f***ing comments”
a user of a popular US news site
!
4. There are a lot of patterns
Some have been superseded
28. HTML is almost the same
!
<button class="button-toggle" data-toggle>Menu</button>
!
<div class="brand">Logo</div>
!
<nav class="navbar">
<ul class="navbar--items">
...
</ul>
</nav>
...
30. Determine the type of event
var click = 'click';
!
if (document.documentElement.hasOwnProperty('ontouchstart')) {
click = 'touchstart';
}
31. Select the elements with the attribute
var click = 'click';
!
if (document.documentElement.hasOwnProperty('ontouchstart')) {
click = 'touchstart';
}
!
var toggleButtons = document.querySelectorAll('[data-toggle]');
32. Create a function to toggle the class
var click = 'click';
!
if (document.documentElement.hasOwnProperty('ontouchstart')) {
click = 'touchstart';
}
!
var toggleButtons = document.querySelectorAll('[data-toggle]');
!
function toggle(ev) {
ev.preventDefault();
ev.target.classList.toggle('is-on');
}
33. Associate the elements with the function
var click = 'click';
!
if (document.documentElement.hasOwnProperty('ontouchstart')) {
click = 'touchstart';
}
!
var toggleButtons = document.querySelectorAll('[data-toggle]');
!
function toggle(ev) {
ev.preventDefault();
ev.target.classList.toggle('is-on');
}
!
/* Put everything togther */
for (var i = 0; i < toggleButtons.length; i = i + 1) {
toggleButtons[i].addEventListener(click, toggle, false);
}
68. Resources
All the code used in this presentation
github.com/dp-lewis/respond
!
Heaps of info about RWD
bradfrost.github.io/this-is-responsive
!
Easy to reach places on devices
lukew.com/ff/entry.asp?1649
!
Standardising the Icon
bit.ly/standardise-icon