{"id":34546,"date":"2016-09-23T05:33:20","date_gmt":"2016-09-23T09:33:20","guid":{"rendered":"http:\/\/www.shamusyoung.com\/twentysidedtale\/?p=34546"},"modified":"2016-09-23T05:33:20","modified_gmt":"2016-09-23T09:33:20","slug":"site-theme-3","status":"publish","type":"post","link":"https:\/\/www.shamusyoung.com\/twentysidedtale\/?p=34546","title":{"rendered":"Site Theme"},"content":{"rendered":"<p>It&#8217;s amazing how easy it is to fall into common pitfalls of software engineering, even when you&#8217;ve run afoul of them before and you should supposedly know better.<\/p>\n<p>Today&#8217;s pitfall is &#8220;scope creep&#8221;, where a small, sensible change gradually grows into something large, ambitious, and impractical.<\/p>\n<p>I needed to add a byline to the end of each post. This wasn&#8217;t required when 99% of the posts on the site were authored by me, and those last 1% were unexpected edge-cases where it was usually pretty obvious who wrote the thing. But these days I&#8217;m only writing ~75% of them, and so it&#8217;s really important to make it clear who the author is. I know from experience that most people ignore the name at the top of the post. So I added a little bio and a link to the author&#8217;s Patreon to the end of the article.<\/p>\n<p>But hey, while I&#8217;m here making changes&#8230;<\/p>\n<p><!--more--><\/p>\n<h3>This is Probably a Bad Idea<\/h3>\n<p>I&#8217;ve always liked the parallax effect you see on some websites. That&#8217;s when the main content scrolls normally, but the background scrolls slowly. The effect is to give the website some visual &#8220;depth&#8221;. It&#8217;s also good because &#8211; unlike most other HTML bling &#8211; it&#8217;s not mechanically obtrusive. The problem with animated menus, fancy cursors, fading image effects, roll-out content, and other graphical trickery is that they break from expected behavior and make the site harder to use. <\/p>\n<p>Say you want to click at the top of a site to go back to the front page, but the shitty Javascript causes a little stutter as your mouse pointer passes over the menu bar. This stutter makes you mis-click into the stupid menu that just rolled out, and now you&#8217;re being whisked away to some random bit of the site. You saw the menu had the entry HOME in it, so you try to open the menu again. This time you mis-click because the rollout animation presents you with a moving target. And then you figure this website is too much bother and go somewhere else to read your gaming news. <\/p>\n<p>But parallaxing is entirely visual. It&#8217;s just a moving background. By design, it doesn&#8217;t impact anything interactive. This is a good place to add useless effects that won&#8217;t mess with usability. And if it fails because of some browser compatibility nonsense (everyone is looking at YOU, Internet Explorer) it won&#8217;t hurt anything. The worst-case scenario is that the background will scroll normally. <\/p>\n<p>That was my thinking, anyway.<\/p>\n<p>So I looked up how to do the parallaxing effect. Every tutorial began with a &#8220;simple&#8221; bit of Javascript that filled half a page and looked like <a href=\"http:\/\/www.ioccc.org\/\">obfuscated C<\/a>. I wasn&#8217;t interested in those. I don&#8217;t like Javascript for a hundred reasons I won&#8217;t belabor here, not the least of which is that when your site already runs on PHP, HTML, and CSS, adding yet another scripting language seems like asking for trouble. I know WordPress uses Javascript to accomplish some of its sorcery (like editing comments) but those bits are all safely hidden under the WordPress hood. I don&#8217;t want to add Javascript that <em>I&#8217;m<\/em> responsible for.<\/p>\n<p>So I went looking for one that gets the job done with just HTML and CSS. And <a href=\"http:\/\/keithclark.co.uk\/articles\/pure-css-parallax-websites\/\">I found one<\/a>. It took some doing to make it work with my theme. It wasn&#8217;t exactly plug-and-play. I had to mess with the page structure a bit. And then I spent a good hour trying to figure out WHY the background was leaving a ten-pixel gap on the left. There are about five thousand different things that can create a ten-pixel gap in CSS, so it was a long, stupid, annoying search and in the end I gave up and used a background image that could hide the problem. <\/p>\n<p>Well, all I needed to do was add a byline, but I ended up blowing an afternoon on something pointless. But sometimes pointless effects are fun. There were probably better ways I could have invested those hours, but whatever. At least it&#8217;s done now. I uploaded the change to the site. I scrolled up and down to see the fun parallaxing in action. Everything looked good.<\/p>\n<p>And then I hit PAGE UP to return to the top of the page. Nothing happened.<\/p>\n<p>Head. Hit. Keyboard.<\/p>\n<p>So what&#8217;s happening is this: To create the effect in HTML, you have to make the parallaxing happen in a container. The container is fixed to be exactly the size of your screen. This means the right-hand scrollbar isn&#8217;t used (or even visible) because there&#8217;s no vertical scrolling to be done. The scrollbar you see on the right is actually the scrollbar for the container. (Note my twitter feed in the right-hand sidebar. It&#8217;s the same thing. A little rectangle of space with its own local scrollbar.) But while container scrollbars can use the normal scroll wheel controls, they don&#8217;t respond to the keys that govern site navigation: Page Up, Page Down, Home, and End. <\/p>\n<p>I even tested all of this on my staging site just to make sure it would work properly before I made it all live. It just never occurred to me to test the Home \/ End keys.<\/p>\n<p>Maybe there are other ways of getting this done that won&#8217;t exhibit this problem, but I&#8217;ve already sunk enough time into this boondoggle. I&#8217;m going to remove the parallax and go back to a fixed background. The result is that the site is going to look a little plain<span class='snote' title='1'>As of this writing, the background is pure white because I haven&#8217;t adjusted the old backgrounds to work with the next layout.<\/span> until I get motivated enough to find another way to spice things up.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s amazing how easy it is to fall into common pitfalls of software engineering, even when you&#8217;ve run afoul of them before and you should supposedly know better. Today&#8217;s pitfall is &#8220;scope creep&#8221;, where a small, sensible change gradually grows into something large, ambitious, and impractical. I needed to add a byline to the end [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[111],"tags":[],"class_list":["post-34546","post","type-post","status-publish","format-standard","hentry","category-notices"],"_links":{"self":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/34546","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=34546"}],"version-history":[{"count":0,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/34546\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=34546"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=34546"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=34546"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}