Showing posts with label CSS. Show all posts
Showing posts with label CSS. Show all posts

Monday, June 10, 2013

A vertical image slider with jQuery and Plone's Products.Carousel

My goal was to create a vertical sliding effect to allow a visitor to experience tall images in a small area.
The images were made too tall for the viewing area and then, using jQuery's animate, were made to slide upwards through the viewing area. I used Products.Carousel but I'm sure a similar effect could be achieved with collective.carousel.

Products.Carousel is a Plone add-on that provides a point and click interface for managing banners, this makes it possible to appoint non-technical persons as banner administrators. Products.Carousel also builds on Plone's built-in workflow support so banners can be scheduled for publication and expiration among other things.

(Products.Carousel has a simple javascript event system with basic documentation (see: http://plone.org/products/carousel/#carousel-events), so it is possible to take advantage of event listeners to do fancier stuff).

The Structure

The viewing area is wrapped with the css selector span.carousel-image 
The carousel images can be selected based on a general selector such as .carousel img or based on the unique id associated with the slider

The Implementation

The key ideas are as follows:
  • We add custom css to match the viewing area class (called "carousel-image") to size we configure for the carousel.
  • We make the source images taller than the carousel viewing area.
  • We add custom css that enforces the height of the carousel images so they inherit the viewing area size.
  • We add custom javascript which will slide the image through the viewing area and is triggered upon changing of slides.

The CSS

To save on further explanation I've included annotations that explain the key CSS (There is other supporting CSS but it is more incidental to the functionality). In this example the carousel has the unique id "carousel-14937891799".

/*
 rule for image, overrides the default image size and enforces
the height of the carousel images to 400px tall
 */
#carousel-1493789179 img {
width: 961px;
height: 400px;
position:relative;
}
/* rule for the span on top of the image.
switches it to behave like a block then makes the viewing area only
200px tall while preventing overflow
 */
.carousel-image {
height: 200px;
overflow: hidden;
display: block;
}

The Javascript

I had to use a CSS Inspector (the one that comes with Chrome) to determine the ideal displacement of the image which worked out to be 197px. Here's the jQuery animate syntax.
jQuery('.carousel img').animate({top:"-=197px"},9000);

A simple and complete script might look like this (In my case I just added the line to a existing jquery custom script that runs on load).:

jQuery(document).ready(function () { 
     jQuery('.carousel img').animate({top:"-=197px"},9000); 
)}; 
update: I decided to make use of Products.Carousel's event system, as a result I added the following lines of code to my custom javascript:

jQuery(document).ready(function () {

    $("#carousel-1493789179 img").animate({top: "-=197px"})
/* reset the slides to the top just before animation */
    $('.carousel').bind('beforeAnimate',

        function () {

             jQuery('.carousel img').css('top','0px');

        });

/* initiate slide up animation after a new slide has been displayed (ie. on new animation) */

    $('.carousel').bind('afterAnimate',

        function () {

            jQuery('.carousel img').animate({top:"-=197px"},6000);

         });

)};

Parting Thoughts

There are some weaknesses with this approach, for example it assumes that all banner images will always be 400px high. When there are multiple images in the Carousel the sliding up effect is lessened, this can be improved by tying the slide up effect to a Carousel event. It would also be good to add some easing for a smoother scroll effect.

Currently the script is fired even if there is no carousel present, making it detect the presence of a carousel first is a sensible next feature.

It might be useful to package this as an add-on for Products.Carousel so that it is 100% site administrator friendly in the future.

For the record, this was easier to do, back in the day with Flash, but then Android and iOS users would not be able to see it, plus my primary machine is now a Chromebook so there isn't much of an option for using the Flash IDE anyway. I would still be left to do the integration work so that mortals could manage the system when we're done.

Wednesday, December 26, 2012

Teaching Web Stuff - Paid Micro-Workshops

In the near future I will be running a handful of paid micro-workshops on web related topics. The idea is that each workshop will address one thing well. I hope this will be fun for myself and the participants.

Audience

The audience I'm aiming for is as follows:
Smart persons with limited time looking for guided learning. 
Each workshop will be concise, and there should be a low barrier of entry for the right participants. As a result, with very little exception, these will be online workshops.

Sign up

I've put together a sign up form for those who want to be the Lab Rats Pioneers :) Subscribe now (http://eepurl.com/toOof). Fill it out and I'll follow up with you.

Cost

$30 per person per micro-workshop.

Vote on Topics

I've set up a uservoice forum so you can up vote the topics you want to see delivered first.

Structure of a Micro-Workshop

Short. Thoroughly prepared. It should be possible to deliver a micro-workshop within 60 minutes, this includes a window of 20 minutes for questions and interaction. 

Topics

The topics are all web related and are I based on things that I have attained a reasonable of facility in. So far I've identified the following topics:
  • Bash Scripting Fundamentals
  • Plone Content Management
  • Visual Design for Developers - helping developers use CSS to make stuff look good
  • CSS Baby steps for designers
  • An introduction to Cloud9 IDE

Schedule

All things being equal the first workshop will run on January 2, 2012

Other Thoughts

Some persons may be interested in additional guidance so I'm working on how I might be able to offer optional after workshop support. 


Saturday, December 22, 2012

Google Web fonts not showing in Google Chrome? Could be an HTTP/S protocol mismatch

Symptom:

Your Google web font doesn't work when testing it in Google Chrome.

How to reproduce the error:

You go to Google Webfonts, select a font and choose "Quick use".
You paste the code into the correct location of your html or css file and then, using CSS, set rules that use the font. But the font doesn't work. Check one more thing, is your webpage being served via HTTPS? I thought so.

Diagnosis:

Most likely you are loading your google web font as an HTTP resource when your page is being served via HTTPS. Make sure that the google web font URL is also being served via HTTPS.

As far as Chrome is concerned, a page served as HTTPS should not be calling a resource served as HTTP. Chrome isn't picky about when things are the other way around, so it will happily retrieve an HTTPS resource via a page served as HTTP. The solutions listed below reflect this understanding of Chrome.

Solutions

Option 1 - match the protocols

Make sure you always call the https version of your Google Webfont URL.  For example:

@import url(https://fonts.googleapis.com/css?family=Alfa+Slab+One);
or

<link href='https://fonts.googleapis.com/css?family=Alfa+Slab+One' rel='stylesheet' type='text/css'>

Option 2 - don't specify the protocol

Most modern browsers don't actually require that you specify the protocol, they will "deduce" the protocol based on the context from which you called it, so it is usually safe to specify the URL as follows:

@import url(//fonts.googleapis.com/css?family=Alfa+Slab+One);


or

<link href='//fonts.googleapis.com/css?family=Alfa+Slab+One' rel='stylesheet' type='text/css'>


Further Troubleshooting

If it still isn't working, check that your browser cache is properly cleared.

Thursday, September 15, 2011

3 must read books for newbie web designers

 http://www.20thingsilearned.com
This is both a technology demostration and valuable education resource. The book makes excellent use of the new HTML5 technologies why teaching valuable lessons about the web, the internet and web browsers. 



A series of tutorials that will walk you from beginner to advanced in the essential web technologies of HTML and CSS.



http://eloquentjavascript.net
I'll be honest and say that this is one that I haven't read yet, but it's on my reading list because the outline is really good. I think it will make teaching javascript a bit easier for me.








Once you've covered the basic technologies then you want to learn the processes associated with web management so head to:

 http://webstyleguide.com/


After that you'll want to learn a bit about content management systems and web languages. I have a preference for Plone and Python.

Background on these web books
Some one recently asked me about learning Web Development. In answering them I came up with what I consider an very good web learning roadmap.

Thursday, April 1, 2010

TTW Plone for Designers – Part 1

If you missed it, or just want to quickly revise the course material,
visit the video on demand (sorry about the ridiculous lack of
lighting):
http://www.livestream.com/pigeonflight/video?clipId=flv_47945cb1-281c-40da-857c-1cb474b973c7

I've noted some special times in the video so you don't have to endure
all the bumbling:

Watch live streaming video from pigeonflight at livestream.com


Content

18:20 - Purpose of Course
21:30 - Adding Objects via the ZMI
29:30 - Understanding Page Templates
33:10 - Using TAL (tal:content) in Page Templates
39:00 - Creating a Dynamic List with Page Templates
49:40 - Using Macros (METAL) in Page Templates
55:00 - Basing a Page on a Template (sorry about the bad sound here)
1:00:25 - Tour of A Fancy Site Template based on a free template
1:05:30 - Creating a Navigation Bar Menu for the Site
1:14:25 - Using Page Templates with metal:fill-slot to create a slideshow page
1:39:40 - Brief Tour of Plone

Errata
---------
During the presentation I referred to the basic site example as a
Plone Site (if you were keen you would see that it was clearly not a
Plone site, but a basic Zope site built with Page Templates)

Monday, October 19, 2009

960.gs css grid framework, mockups and failing fast

Finally I've gotten around to making use of one of these css grid frameworks. Based on some cursory research I decided to use the 960.gs framework.

Why I like 960.gs

No new knowledge - This framework builds on my existing css knowledge, it doesn't require me to install ruby/java and compile my css or any weirdness like that

Easy to learn - The principles are very easy to learn, this is important and usually means there will be good adoption of the tool.

Fast to get started - Being able to quickly test out new ideas is a big win, I believe in the concept of "fail fast". Anything that speeds up your "idea-test-implement cycle" is potentially valuable.

Documentation and Examples - Even though it's dead simple, examples and tutorials are always helpful, thankfully, these weren't hard to find. It seems 960.gs has gained good momentum.

Day 1 with the 960.gs framework
So what have I done so far? I've been pretty productive with this new framework. I decided to start with my own personal site.

I'm not fully satisfied with the final product, but as a proof of concept, I was able to get the prototype done very quickly, so I consider this to be a good start.
http://img.skitch.com/20091019-xhfwnxa586nkc5d9k76fey2reb.jpg

Most of my time was spent iterating over my logo and getting the mockup done in inkscape.

http://img.skitch.com/20091019-ky7ak7hjnjtiwis7kc35i8fbx9.jpg

I used a grid layout generator to create a 16 column grid which I used as the starting point for laying out my design in css/html. The relevant parts of my mockup were exported from inkscape as PNGs

960.gs in Plone

Using Plone's newly popularized xdv approach to theming, I was able to bring my html almost wholesale into Plone and the result are below. Note that the portlets are still unstyled but this is a good start.

http://img.skitch.com/20091019-x6fxqy6m84jrjn9pfeq2c8uc53.jpg

Friday, October 12, 2007

CSS, every other browser.... then there's IE


[Figure 1]


[Figure 2]

So I'm working on creating a wonderful look for a new website. CSS and design can be so much fun. Looks great in Firefox 2.0.x, Opera and Safari on OS X, but it is always important to check your site in different browsers. So I go to browsershots, figure 1 above shows thumbnails of how the site looks in most browsers, it also happens to be how I designed the site. Figure 2, demonstrates how the site looks in internet explorer (which is, unfortunately, 85% of the internet population and not how I designed it).

So now I move to "phase two" of my design, IEFixes (grrrrrr).

Sign up for my upcoming Plone 5 Book & Video tutorials

plone 5 for newbies book and videos