Improved front-end workflow for Windows

For some time I wanted to improve my front-end workflow. The search for an optimized workflow almost made me switch to mac, and I am still considering the switch. It seems to me that the windows front-end developing environment lacks serious momentum compared to the progress being made on linux and osx.

However now onto the good stuff. I had a few goals for my new workflow; LESS / SASS, auto refresh function, file minification and optional device checking. All this in combination with a proper IDE. At first I gave a shot at Yeoman, the installation with Chocolatey went perfect, however Yeoman itself gave some windows related errors. I am sure Yeoman should work fine, but I like to have my stack divided in several software sections.

The first goal was getting autoreload for the browser. For windows there are several options, all with there own pros and cons.

  • First there is “web essentials” an extension for visual studio, these make it possible to reload the css only. This could be a use full start if your company restricts you to use visual studio for front-end development.
  • Netbeans 7.3 with live html, this is an easy way to get a lot of functionality. However the beta version had difficulties to detect changes made by external compilers. For example css files compiled by the winless less compiler were not detected by the live html functionality. Netbeans live html has the advantage that it works on all file locations, a local server isn’t required.
  • Livereload browserplugin, i use this plugin in combination with sublime text 2. This solution works perfect, combined with some LESS plugins for sublime the less files compile automatically and the updated css file updates the livereload plugin.
  • At last there are a lot of scheduled refresh options, these refresh the browser every on predefined time. I think these options work but are not a very “clean” solution for the problem.

I’m more than happy that I have renewed my workflow, especially “Sublime text” is an instant saver, although it is lacking some deeper IDE functions, like recognizing functions from other files ( If there are some plugin to solve this please share them ). But overall Sublime is an amazing fast and “clean to the eye and mind” editor.

My current stack is as follows; sublime coupled with some less formatting plugins. Less compiling is done with WinLess. Livereload in chrome is coupled with sublime and chrome is optionally connected to devices with Adobe Edge Inspect.
Coding now feels like typing a letter, focused on the code, instantaneous feedback, brilliant 😉

At least until I need to merge the code back into visual studio and TFS, and of course next year there will definitely be new shiny toys.

Making snow: jQuery Snowstorm plugin

check snowstorm demo

Inspired by the current weather in the Netherlands I wanted to make snow with jQuery. A year Ago I would have used flash for this task, and I still believe flash is better for this specific job ( anyone fancies square snow flakes ). However I think the animation still stands strong. Of course the parallax effect and the opacity make the snowstorm realistic as well as the mousemove handler which makes it possible to change the wind direction.

the plugin itself is relatively small and can be found in scripts.js file, I did not make a separate plugin file because this snowstorm plugin is only a start, and most users would customize it extensively

screenshot of the snowstorm

The plugin follows the following steps.


1. interpret the options, and use them in local variables and objects

settings = jQuery.extend({
        width: 640,
        height: 480,
        viewColor: '#000000',
        flakes: 100
    }, settings);
    
    //plugin vars
    var view = this;
    var xOffset = 0;
    var extendedWidth = settings.width*2;

2. create and style the view container

// setView
    var cssObj = {
      'background-color' : settings.viewColor,
      'width' : settings.width,
      'height' : settings.height,
      'margin' : '0px',
      'padding' : '0px',
      'overflow': 'hidden',
      'position': 'relative'
    }
    view.css(cssObj);

3. add a mousemove handler to the view container

// create the mouse move handler
    view.bind("mousemove", function(event)
    {
       xOffset = event.clientX - (settings.width/2) ;
    });

4. create the flakes in a for loop

 //Add the flakes
    for( var i = 0; i < settings.flakes; i++ )
    {
       // extend the possible x beyond the view
       var tx =  Math.ceil(  Math.random()* extendedWidth); 
       var ty = ( Math.ceil( Math.random()*50 ) ) -150; 
       var tsize = Math.ceil( Math.random()*10 + 4 ); 
       var topacity = tsize * 0.1;
       snowFlake( i, tx, ty, tsize, tsize, topacity);
    }

5. Each flake starts it own animation function which call itself again

//Animate each flake
    function animateFlake( flake )
    {
        // animate
        var flakeDelay = Math.ceil( Math.random()*7000 );
        var distanceY  = settings.height + 20;
        var ySpeed =  Math.ceil( (1/flake.width() )*20000 );
        flake.delay(flakeDelay).animate({
          "top": distanceY,
          "left": ("+="+xOffset)
        }, ySpeed, function() 
        {
            //reset flake position
            var cssResetObj = {
              'top': ( -flake.width() + 'px'),
              'left': Math.ceil(  ( Math.random()* extendedWidth)- (settings.width*0.5)  )
            }
            flake.css(cssResetObj);
            animateFlake( flake );
          });
    }

My next steps

After this experiment i want to to realize the same snowstorm with canvas. I am interested in the difference in performance. Of course Canvas should be way way faster because it lacks all the DOM hassle. And it would be possible to create much nicer snowflakes then white squares.