Mobile Safari Webkit Flicking Animation Fix

Back from a little vacation/job change/illness, lets get back to it.

While developing a web based app with some seriously smooth animations behind it I noticed that they would flicker every time they started. Initially I thought it was due to the animation enhancer I had installed. The jQuery animation enhancer seamlessly changes the traditional jQuery animations with the CSS3 animations. On a desktop browser this has mixed results, with safari being faster and chrome being slightly slower, but on an iOS device (in this case an iPad) it was much much faster. Continue reading “Mobile Safari Webkit Flicking Animation Fix”

Better flexible site layout with resize detection.

This is an update to a previous post located here: Flexible site layout with resize detection.

A while back I posted an article about a simple and quick javascript  that would add or remove styles to whatever elements you want based on window width. This is a great way to make a single site compatible with multiple display types, everything from a phone to a desktop with an unreasonable large screen if you’d like. That code used an if statement, and was rather ineffective, I have since rewritten it to be easier to deploy to new themes and came up with this.

Snipplr: http://snipplr.com/view/60562/flexible-site-layout-with-resize-detection-now-improved/

Short, more concise, and easier to implement all you do is create an object with a simple {width: ‘style name’} format and the script will do the rest. It’s then up to you do add all the appropriate styles to your CSS document. This can of course all be done with CSS and the @media tag, but I prefer this method because it simple to deploy and it’s switches are much faster. As always leave a comment with any question or problems and I’ll get back to you as soon as I can.

Super simple inline PHP alternating rows

Traditionally when you have lost lists of dat you want to alternate rows for usability. The first thing everybody makes to fix this is a simple if statement loop, but this adds a number of lines and is hardly a clean solution. Additionally it required you to have a “counter” or “switch” variable, usually placed at the bottom of the loop, overall very messy.

I had a boss who thought he was on the cutting edge by compressing the traditional if statement into a shorthand version (saving 2-3 lines of code), but the system was still using a $class variable and still requires a counting or switch variable. It was still a mess and added clutter to the code that was already cluttered.

Earlier today I was working on outputting client records for the previously mentioned fully customized application. Wanting to avoid such messy code as I’ve seen (and admittedly used) in the past I looked for a better solution and with a little tweaking and playing I came up with this (actually I came up with something similar, that I further optimized at home, but lets not split hairs here).

Snipplr: http://snipplr.com/view/56219/simple-inline-php-alternating-rows/

Thats it, that placed inline in a normal echo statement will place the class alt every other time. It’s a simple modification if you want to call a class tag without adding the key (say you already have a class assigned to it and just want this as a second one, simply place it in the quotes and adjust the code accordingly). Compressed down to a single line it neatly fits into existing code (even HTML with inline PHP like WordPress) and keeps everything clutter free. Heres a simplified snippet of how I deployed it:

Snipplr: http://snipplr.com/view/56219/simple-inline-php-alternating-rows/

I’d usually go over how ti works but it’s pretty straight forward, only thing that might be confusing to newer programmers is how it determines what to output and the general format of shorthand if statements. Simply put the output of putting something into a variable (in this case the ' class="alt" into the $alt variable) is always what you put in (assuming PHP can put it in it, but not being able to is a rather abnormal situation). As for shorthand if statements they are simple; (conditional ? true : false), only disadvantage is that a shorthand if statements are only good for one thing (no multiple lines by inlining ;‘s with it).

I’ve tested this on several servers and it’s haven’t noticed an issue. This is the most compressed alternating row script I’ve seen online, if anybody knows of a reason not to use it (or, if it’s even possible, a shorter version) or uses it in something cool let me know.