Archive for the 'Other' Category

Smooth iPhone Animations

Despite all the excellent iPhone apps out there, one problem hasn’t yet been solved. Specifically, it’s been impossible to produce full-screen, smooth, native-like wipe transitions between “pages.” iUI, Joe Hewitt’s excellent framework for iPhone apps, could only produce 3-5 frames per second, for extremely choppy animations.

Yesterday, I discovered a breakthrough that produces smooth wipes at almost-native speeds. The secret is animating scrollTo instead of trying to move elements. Oddly, scrollTo’s happen at native speeds, while moving elements happen at much slower speeds. It’s akin to getElementsByClassName being baked into a JS implementation vs. having to implement it yourself using JS.

It’s incredibly smooth. Check it out on your iphone at http://www.yehudakatz.com/wp-content/iphone.html

This demo works only in portrait mode, but you get the idea.

ParseTree in Cygwin

So I had a recent need to get parse_tree (which requires RubyInline and thus a compiler) working in Windows. I was told that I could get it working by using some compiler for Windows, but I figured it might be easier to get it working in Cygwin.

That turned out to be only sort of true.

First up, I installed Cygwin with Ruby. I attempted to use irb, and got ‘cannot find ubygems.’ Googling around led to me to the following solution:

unset RUBYOPT

I then needed to install rubygems from scratch, so I grabbed it into my home directory:

wget http://rubyforge.org/frs/download.php/20989/rubygems-0.9.4.tgz

Unpacked it:

tar -xvf rubygems-0.9.4.tgz

Got into the directory, and installed rubygems:

cd rubygems-0.9.4
ruby setup.rb

I then installed parsetree:

gem install parsetree -y

It installed a bunch of dependencies, including RubyInline. So far so good.

When I attempted to load parse_tree from IRB, I got an error about permissions. After a bunch of searching around, I found the answer: make sure the /cygdrive/c directory is not group or world-writable. The easiest solution is:

chmod 700 /cygdrive/c

If you have special needs, you might need to tweak up the chmod command, but you need to keep it from being group or world writable.

And that was it. I loaded IRB and parse_tree worked great!

jQuery on Rails: A (Still Very Alpha) Update

I’ve made a number of updates to my preliminary release of jQuery on Rails:

  • It’s now in svn as part of a demo app, so you can see how it all fits together.
  • The new svn URL is http://jqueryjs.googlecode.com/svn/trunk/tools/rails_demo_app for the entire demo, or http://jqueryjs.googlecode.com/svn/trunk/tools/rails_demo_app/vendor/plugins/jquery_on_rails for just the plugin
  • I added a number of new JavaScript files to get copied when you install the plugin.
  • Your jQuery modules now need to be in app/public/javascripts/jquery_modules, which allows the core library files to be separate from your modules

And the big news…

I’ve written a few proof of concept helpers for jQuery on Rails that come with modules that are automatically installed in jquery_modules.

So far, I wrote one for a tabbed interface and one for sortable tables.

They both take the same settings as the underlying JavaScript libraries. For instance, you can set up the table sorter as follows:

<% sortable_table :sort_class_asc => “ascending”, :sort_class_desc => “descending”, :striping_row_class => ["even", "odd"], :stripe_rows_on_start_up => true do %>
<thead>
<tr>
<th>Col 1</th>
<th>Col 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>jQuery 1.0</td>
<td>$100</td>
</tr>
<tr>
<td>jQuery 1.1</td>
<td>$59</td>
</tr>
<tr>
<td>jQuery 1.1.1</td>
<td>$68</td>
</tr>
<tr>
<td>jQuery 1.1.2</td>
<td>$8</td>
</tr>
</tbody>
<% end %>

This corresponds to:

tableSorter({sortClassAsc: ‘ascending’, sortClassDesc: ‘descending’, stripingRowClass: ['even', 'odd'], stipeRowOnStartup: true})

You can check out both the tablesorter helper and the tabs helper in action by checking out the jQuery on Rails demo app.

Status Update

Hi guys. My previous site got exploited, and I’m still trying to recover the posts. I will hopefully be able to transfer them over sometime this week.

I will be posting again about jQuery and Rails, hopefully more frequently.

Next up: My hpricot-based replacement for assert_select in Rails. Stay tuned!

« Previous Page