File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -611,6 +611,31 @@ <h3 id=the-stylemedia-interface><span class=secno>4.1. </span>The <code
611611 href ="#task "> task</ a > was < a href ="#queue-a-task " title ="queue a
612612 task "> queued</ a > .
613613
614+ < div class =example >
615+ < p > A simple piece of code that detects changes in the orientation of the
616+ viewport can be written as follows:</ p >
617+
618+ < pre > < code > function handleOrientationChange(landscape) {
619+ if(landscape)
620+ …
621+ else
622+ …
623+ }
624+ styleMedia.addMediumListener("(orientation:landscape)", handleOrientationChange)</ code > </ pre >
625+
626+ < p > A more generic handler for media query changes could be written as
627+ follows:</ p >
628+
629+ < pre > < code > function handleMediaQueryChange(query, matches) {
630+ …
631+ }
632+ function addMediumListener(query) {
633+ styleMedia.addMediumListener(query,
634+ function(matches) { handleMediaQueryChange(query, matches) }
635+ )
636+ }</ code > </ pre >
637+ </ div >
638+
614639 < h3 id =the-screen-interface > < span class =secno > 4.2. </ span > The < code
615640 title =""> Screen</ code > Interface</ h3 >
616641
Original file line number Diff line number Diff line change @@ -454,6 +454,29 @@ <h3 id="the-stylemedia-interface">The <code title="">StyleMedia</code> Interface
454454 media query matches the state of the rendered < code > Document</ code > at the
455455 time the < span > task</ span > was
456456 < span title ="queue a task "> queued</ span > .</ p >
457+
458+ < div class ="example ">
459+ < p > A simple piece of code that detects changes in the orientation of the
460+ viewport can be written as follows:</ p >
461+ < pre > < code > function handleOrientationChange(landscape) {
462+ if(landscape)
463+ …
464+ else
465+ …
466+ }
467+ styleMedia.addMediumListener("(orientation:landscape)", handleOrientationChange)</ code > </ pre >
468+
469+ < p > A more generic handler for media query changes could be written as
470+ follows:</ p >
471+ < pre > < code > function handleMediaQueryChange(query, matches) {
472+ …
473+ }
474+ function addMediumListener(query) {
475+ styleMedia.addMediumListener(query,
476+ function(matches) { handleMediaQueryChange(query, matches) }
477+ )
478+ }</ code > </ pre >
479+ </ div >
457480
458481
459482
You can’t perform that action at this time.
0 commit comments