Breaking down CSS Box Shadow vs. Drop Shadow

Post pobrano z: Breaking down CSS Box Shadow vs. Drop Shadow

Drop shadows. Web designers have loved them for a long time to the extent that we used to fake them with PNG images before CSS Level 3 formally introduced them to the spec as the box-shadow property. I still reach for drop shadows often in my work because they add a nice texture in some contexts, like working with largely flat designs.

Not too long after box-shadow was introduced, a working draft for CSS Filters surfaced and, with it, a method for drop-shadow() that looks a lot like box-shadow at first glance. However, the two are different and it’s worth comparing those differences.

For me, the primary difference came to light early on when I started working with box-shadow. Here’s a simple triangle not unlike the one I made back then.

See the Pen CSS Caret by CSS-Tricks (@css-tricks) on CodePen.

Let’s use this to break down the difference between the two.

Box Shadow

Add a box-shadow on that bad boy and this happens.

See the Pen CSS Caret Box Shadow by CSS-Tricks (@css-tricks) on CodePen.

It’s annoying, but makes sense. CSS uses a box model, where the element’s edges are bound in the shape of a rectangle. Even in cases where the shape of the element does not appear to be a box, the box is still there and that is was box-shadow is applied to. This was my „ah-ha moment” when understanding the box in box-shadow.

CSS Filter Drop Shadow

CSS Filters are pretty awesome. Take a gander at all the possibilities for adding visual filters on elements and marvel at how CSS suddenly starts doing a lot of things we used to have to mockup in Photoshop.

Filters are not bound to the box model. That means the outline of our triangle is recognized and the transparency around it is ignored so that the intended shape receives the shadow.

See the Pen CSS Caret Drop Shadow by CSS-Tricks (@css-tricks) on CodePen.

Deciding Which Method to Use

The answer is totally up to you. The simple example of a triangle above might make it seem that filter: drop-shadow() is better, but it’s not a fair comparison of the benefits or even the possibilities of both methods. It’s merely an illustration of their different behaviors in a specific context.

Like most things in development, the answer of which method to use depends. Here’s a side-by-side comparison to help distinguish the two and when it might be best to choose one over the other.

Box Shadow Drop Shadow
Specification CSS Backgrounds and Borders Module Level 3 Filter Effects Module Level 1
Browser Support Great Good
Supports Spread Radius Yes, as an optional fourth value No
Blur Radius Calculation is based on a pixel length Calculation is based on the stdDeviation attribute of the SVG filter
Supports inset shadows Yes No
Performance Not hardware accelerated Hardware accelerated in browsers that support it. It’s a heavy lift without it.

Wrapping Up

The difference between box-shadow and filter: drop-shadow() really boils down to the CSS box model. One sees it and the other disregards it. There are other differences that distinguish the two in terms of browser support, performance and such, but the way the two treat the box model is the key difference.

Update: Amelia identified another key difference in the comments where the spread of the radius for drop-shadow() is calculated differently than box-shadow and even that of text-shadow. That means that the spread radius you might specify in box-shadow is not one-to-one with the default spread value for drop-shadow, so the two are not equal replacements of one another in some cases.

Let’s cap this off with a few other great examples illustrating that. Lennart Schoors also has a nice write-up with practical examples using tooltips and icons that we previously called out.

See the Pen Drop-shadow vs box-shadow (2) by Kseso (@Kseso) on CodePen.

See the Pen box-shadow & drop-shadow by qnlz (@qnlz) on CodePen.

See the Pen Drop-shadow vs box-shadow (3) en png´s by Kseso (@Kseso) on CodePen.


Breaking down CSS Box Shadow vs. Drop Shadow is a post from CSS-Tricks

Design deals for the week

Post pobrano z: Design deals for the week
first image of the post

Every week, we’ll give you an overview of the best deals for designers, make sure you don’t miss any by subscribing to our deals feed. You can also follow the recently launched website Type Deals if you are looking for free fonts or font deals.

10+ Best-Selling Premium Fonts

Make room in your typeface toolbox! It’s time to grab this sweet deal full of more than 10 premium best-selling font families. From Charlie to Sweetie to Sharpeye Type, you’ll get a wonderful variety of fun, curvy fonts that will work perfectly with your latest designs. Use them on everything from T-shirts to logos.

$14 instead of $114 – Get it now!

80 Beautiful, Liquid Style Brushes

Want to add a bit of motion to your designs? Consider a Fast Style approach using this collection of 80 Liquid Style Brushes. These brushes feature a modern-yet-retro digital style that creates round-ended lines giving off an almost dripping appearance. Use the handy reference guide to quickly choose the right brush to whip up a clean illustration or icon.

$9 instead of $15 – Get it now!

Over 1,300 SVG Cut Files & Razberry Font

Looking to add some unique graphics or sayings to your latest design project? Then check out this huge giveaway from lovesvg.com! You’ll get over 1,300 scalable vector graphics full of everything from adorable owls to caffeine-fueled phrases. A bonus Razberry font full of 18 more SVGs is the perfect cherry on top of this super designer sundae.

$15 instead of $3000 – Get it now!

120+ Unique, Premium Typefaces – 31 Font Families

It’s time to fall into a fantastic font sale! This Autumn Font Sale is overloaded with more than 120 gorgeous typefaces, culled from 31 different font families. You’ll be privy to a wide variety of styles ranging from vintage to cartoony, not to mention a slew of extras like alternates. No matter your latest project, you’re bound to find the perfect font in this collection.

$9 instead of $1550 – Get it now!

How to Draw a Mystic Moon Illustration in Procreate on iPad

Post pobrano z: How to Draw a Mystic Moon Illustration in Procreate on iPad

Final product image
What You’ll Be Creating

The moon has always attracted people, not only from a scientific point of view as an astronomical object, but also because it is believed to have some magical aspects which influence our lives. It can even be frightening and sometimes creepy! 

If you’ve ever heard of selenophobia, you probably know what I mean. Selenophobia (from the Greek word seleno, meaning „moon”), also known as lunaphobia (from the Latin word luna, meaning „moon”) is the fear of the moon. Like many other phobias, selenophobia originates from painful experiences during childhood.

You may believe it or not, but as for now, let’s get some inspiration from this side of the moon’s nature and draw a mysterious illustration in Procreate. We’ll start with a very rough sketch, discovering all the basic features of this drawing application, and gradually moving to building shapes, colouring them, and adding textures up to the end result. Interested? 

Oh, and by the way, you can get the Mystic Moon source file together with other file formats on Envato Elements. This file will allow you to see how everything was made and organised by going through the layers. You will also get a layered Adobe Photoshop file which is convenient to use for your personal or commercial work. 

Let’s begin!

1. How to Draw a Moon in Procreate

Step 1

I’m using an iPad Pro and an Apple Pencil to create illustrations in Procreate. However, Procreate also supports other models of iPads (with iOS 10.0 and newer) which work with other styluses listed in Actions > Devices. The Apple Pencil itself is not on the list, though all its functions are fully supported by the app as well. While choosing your device or stylus, please keep in mind that Apple Pencil works only with iPad Pro, so always check the full information and compatibility of devices and apps before purchasing.

supported devices

Step 2

Open the application, and let’s create a New Canvas by clicking the Create (+) icon in the top right corner. From there we can either select one of the canvases from the list or create a custom one. The number of layers in our file depends on its size. The higher the dimensions, the fewer layers you’ll be able to create. 

Let’s make a 3500 x 3500 px canvas that will allow us to make up to 12 layers, which is more than enough for this project.

create new canvas

Step 3

I usually start my illustration with a rough sketch. Let’s open the Brushes tab and select an HB Pencil brush from the Sketching set. 

We already have one empty layer by default, so I just pick the brush and start doodling. I can control the Size and Opacity of my brush by moving the two vertical sliders on the left side of the screen.

pick a brush and make a sketch

Step 4

Once I’m happy with the overall idea of my future illustration, I open the Layers panel and tap the layer to reveal a menu. Tap Rename and change the layer name to “Sketch”.

rename a layer

Step 5

Here is what I ended up with. It is pretty simple yet detailed, which will help me to focus on shapes and colours.

sketch of future illustration

Step 6

As you may have noticed, we already have a “Background colour” layer in the Layers panel by default. It allows us to change the colour of the canvas by tapping and selecting the desired colour on the colour wheel. Let’s pick a nice tint of dark blue for the night sky.

change background color

Step 7

Now let’s tap the “+” icon in the top right corner of the Layers panel to make a New Layer. Then open the Brushes panel and pick the Ink Bleed brush in the Inking set.

pick a brush

Step 8

If we swipe to the left through all the brush sets, we can tap the “+” icon and create a New Set. Then we can drag and drop any existing brushes in this set for quick access.

Apart from that, we can edit the settings of any brush by tapping it. Let’s tap the Ink Bleed brush and edit the Stroke > Streamline parameter by setting it to 5%. This function allows us to smooth the line while drawing, which gives higher control over the strokes.

Then go to General > Size Limits and make sure that the Max slider is set to maximum.

create a new set and open brush settings

Step 9

Now we can pick the pale yellow colour on the colour wheel (top right corner) and draw the outline of the moon, using our sketch as a reference. We can also pinch the canvas with two fingers, zoom it, and rotate for our convenience.

I also move the Size and Opacity sliders all the way up to make the line thick and solid.

make an outline

Step 10

Once we’ve created a closed path, we can either scribble inside to fill it with colour or we can tap and hold the colour circle in the top right corner and drag and drop it right onto our shape.

fill the shape with color

Step 11

Let’s open the Layers panel and tap the N letter on the Sketch layer. From here, we can switch between the Blending Modes and change the Opacity of the layer. Set the Opacity to 45%, making the sketch semi-transparent.

change the layer opacity

Step 12

When using a textured brush, you may notice some empty spots or strokes after filling the shape. Use the Ink Bleed brush to paint inside the shape, eliminating the blank spaces.

fill the blank spots

Step 13

Now let’s Alpha Lock our moon layer by swiping to the right with two fingers. You will see the layer thumbnail background become checkered. Once you’ve Alpha Locked the layer, you’ll be painting inside the shape, without crossing its edges, which is very convenient for adding shadows, highlights, and textures.

alpha lock the layer

Step 14

Now let’s add some texture to our moon. First of all, let’s select a darker colour. If you already have another colour selected, tap the square that’s located between the Size and Opacity sliders, and move the magnifying circle on top of the moon to pick its pale yellow colour. 

Open the colour wheel and select a darker colour.

pick a color

If you want to change the options of the colour picker, you can go to Actions > Advanced gesture control and switch between the settings of the Eyedropper.

options of procreate

Step 15

Let’s go to Brushes > Sketching and pick the Bonobo Chalk brush. Lower the Opacity and start painting over the moon, adding texture.

pick a textured brush

Step 16

Now lower the Size and draw along the edges of the moon to make it more three-dimensional.

add shadow along the edge

Step 17

Now let’s create a New Layer, pick an orange colour, and choose the HB Pencil brush. Start scribbling over the darker areas, adding a realistic pencil texture. Make short parallel hatches, the same way as you do it on paper.

make pencil strokes

Step 18

Continue adding pencil strokes along the edges. Then pick a light-yellow colour and fill the center of the crescent as well.

Here you can see the layers that we’re using in this step.

add more pencil strokes

Step 19

Let’s make a New Layer and take the Ink Bleed brush. Use a dark-orange colour to add short strokes for a cartoon effect.

Lower the Opacity of the layer to 60%, making the strokes semi-transparent.

add short strokes

Step 20

Now that our moon is finished, let’s Group all of its layers together. Select the top layer and swipe to the right all the layers beneath it with one finger. You will see a light-blue selection and a three-strokes icon appear in the top right corner of the Layers panel. Tap the icon to create a Layer Group. Now we can rename it and fold by tapping the arrow icon.

create a layer group

2. How to Draw a Star

Step 1

Let’s unlock the alpha on the Moon layer by swiping it to the right again with two fingers. You will see a solid background on the layer thumbnail, meaning that now you can paint anywhere on this layer.

Let’s use the Ink Bleed brush again to draw a star that we have on our sketch layer.

draw a star

Step 2

I want to move the star a bit as I don’t like its current position. It looked fine on the sketch, but now the composition is quite unbalanced, so let’s see how we can center its top point with the top tip of the crescent.

Let’s tap the Freehand Selection in the top panel and make sure that Freehand option is selected in the bottom panel. Now we can draw a circle around our star, creating a selected area.

use freehand selection

Step 3

After the selection is created, tap Transform and select Freeform in the panel below. Now that our selection around the star has changed to a square, we can move it around without affecting any other elements on the same layer.

use the transform tool

Step 4

Use the Bonobo Chalk brush and switch to lighter and darker yellow colours, adding that texture touch to the star and making it more three-dimensional.

add texture to the star

Step 5

Both main elements of our composition are ready, so let’s make them pop out of the background a bit more.

Create a New Layer right above the Background colour layer. You can reorder the layers by simply tapping and holding a layer and then dragging and dropping it to the desired position in the Layers panel.

Use the Bonobo Chalk brush and a dark blue colour (slightly lighter than the background) to create a subtle mist around the moon.

add lighter color to the background

3. How to Draw Floral Elements and Herbs

Step 1

Now let’s unleash our imagination and draw out all those herbs and flowers from our sketch by adding more details and life to them.

Create a New Layer, take the Ink Bleed brush, and start drawing out the first branch growing from the bottom tip of the crescent. I’m using a dark-blue colour for this one, starting with a thin, arched stem and then adding rounded leaves along the stem.

draw a floral element

Step 2

Continue using the same colour to add more elements around the moon. First of all, add a few floating leaves next to the first branch. Then draw a second branch growing from the bottom of the crescent. Place it right above the yellow surface, thus adding contrast.

Move on by adding other branches and leaves. I’m also using the Erase tool with the same Ink Bleed brush, cleaning some spots where I don’t want the leaves to overlap with the yellow shape of the moon.

add more leaves and elements

Step 3

Once you’re happy with the dark blue plants (by the way, you’re always able to return to them later and add whatever details you want), create a New Layer and use a greyish-blue colour to add those leaves and flowing stems. Make the new grey plants partially overlap the dark-blue ones from the previous layer.

Try to maintain the balance in your composition by adding branches of more or less equal length on both sides of the moon. Don’t forget about the floating leaves—speckle them around the branches as well.

draw plants of other color

Step 4

Now it’s time to create the next New Layer. Pick a light-yellow colour and start adding bright strokes to our image in the spots where they are really needed.

add brighter elements

Step 5

I have some plants here that consist of a grey stem and light-yellow flower bud. In order to add those buds, I simply create a New Layer and place it beneath all the other floral layers so that my additional yellow elements will always be partially hidden beneath the top layers of herbs.

add yellow buds on a new layer

Step 6

Once I’m happy with all the flowers and plants, I make sure that everything looks balanced enough and there are no empty spots or, on the contrary, areas overloaded with elements. 

I’m using one of the yellow layers to speckle some stars around the moon by drawing dots of various sizes with the Ink Bleed brush.

add yellow stars around the moon

Step 7

Now it is time to add a textured touch to all the floral elements! Don’t worry, you won’t have to draw a shadow on each leaf and flower manually. 

First of all, let’s Alpha Lock each of the floral layers by swiping to the right with two fingers. If you do everything right, you will see a checkered background on the thumbnails.

Now take the Bonobo Chalk brush, and let’s start with the dark blue layer. Select a darker colour and go over the layer with wide strokes, adding grainy texture to all the dark-blue pieces. Then decrease the Size of the brush and go over the areas that need some more intense shadows, like the places where the leaves overlap or the spots where leaves grow from the stem, making the stem darker. This way we’ll visually separate the layers from each other, bringing more dimension to our image. 

add texture to the leaves

Step 8

Now let’s blend in some highlights. Pick a lighter yellow colour and draw over the tips of the leaves, adding a subtle silver glow to them.

add texture to the leaves 2

Step 9

Work over all the dark blue layer and don’t forget to zoom out in order to check how the overall image looks at this stage.

add texture to the leaves 3

Step 10

Now let’s switch to the grey layer and do the same for the greyish-blue plants. Start by adding those shadows and go on to the highlights, making all the tips slightly lighter.

add texture to the leaves 4

Step 11

And finally, the yellow layers (both top and bottom ones)! This time, try to achieve a golden look by using orange for the shadows and light yellow (almost white) for the highlights.

add texture to the leaves 5

Step 12 

Once you’re happy with the floral elements, make a New Layer on top of all the floral layers, and let’s add some more mystic glow. Go to Brushes and select Airbrushing > Soft Airbrush. Pick a light-yellow colour.

take a soft brush

Step 13

Decrease the Opacity and draw very light round spots around all the yellow-gold elements, making them really stand out and glow.

add glow to yellow elements

Step 14

We can add some more volume to our image if we create a New Layer in the Moon group of layers (Shadow layer) and use the Bonobo Chalk brush to make subtle shadows in the areas where leaves are placed on top of the moon. We can play with the layer options by setting it to Multiply mode and decreasing the Opacity to 80%, making it more subtle.

add shadow to the moon

To the Moon & Back! Our Mystic Moon Image Is Finished!

Great work! Now our mystic moon illustration looks balanced and complete! I hope you’ve enjoyed following this tutorial and discovered new opportunities of using your iPad as a fully featured working device while creating beautiful pieces of art in Procreate.

By the way, once you’ve finished with your image, you can always share it and export in multiple formats, including the original Procreate file and a layered PSD file for Adobe Photoshop, which gives you even more flexibility and a wider range of opportunities! 

mystic moon is finished

You can get the Mystic Moon file in various formats on Envato Elements, to see how it was made and how the layers are organised. Apart from that, you’ll get a layered PSD file which is easy to use for your personal or commercial designs.

Creating Vue.js Transitions & Animations

Post pobrano z: Creating Vue.js Transitions & Animations

My last two projects hurled me into the JAMstack. SPAs, headless content management, static generation… you name it. More importantly, they gave me the opportunity to learn Vue.js. More than „Build a To-Do App” Vue.js, I got to ship real-life, production-ready Vue apps.

The agency behind Snipcart (Spektrum) wanted to start using decoupled JavaScript frameworks for small to medium sites. Before using them on client projects, however, they chose to experiment on themselves. After a few of my peers had unfruitful experiences with React, I was given the green light to prototype a few apps in Vue. This prototyping morphed into full-blown Vue apps for Spektrum connected to a headless CMS. First, I spent time figuring out how to model and render our data appropriately. Then I dove head first into Vue transformations to apply a much-needed layer of polish on our two projects.

I’ve prepared live demos on CodePen and GitHub repos to go along with this article.

This post digs into Vue.js and the tools it offers with its transition system. It is assumed that you are already comfortable with the basics of Vue.js and CSS transitions. For the sake of brevity and clarity, we won’t get into the „logic” used in the demo.

Handling Vue.js Transitions & Animations

Animations & transitions can bring your site to life and entice users to explore. Animations and transitions are an integral part of UX and UI design. They are, however, easy to get wrong. In complex situations like dealing with lists, they can be nearly impossible to reason about when relying on native JavaScript and CSS. Whenever I ask backend developers why they dislike front end so vehemently, their response is usually somewhere along the lines of „… animations„.

Even for those of us who are drawn to the field by an urge to create intricate micro-interactions and smooth page transitions, it’s not easy work. We often need to rely on CSS for performance reasons, even while working in a mostly JavaScript environment, and that break in the environment can be difficult to manage.

This is where frameworks like Vue.js step in, taking the guess-work and clumsy chains of setTimeout functions out of transitions.

The Difference Between Transitions and Animations

The terms transition and animation are often used interchangeably but are actually different things.

  • A transition is a change in the style properties on an element to be transitioned in a single step. They are often handled purely through CSS.
  • An animation is more complex. They are usually multi-step and sometimes run continuously. Animations will often call on JavaScript to pick up where CSS’ lack of logic drops off.

It can be confusing, as adding a class could be the trigger for a transition or an animation. Still, it is an important distinction when stepping into the world of Vue because both have very different approaches and toolboxes.

Here’s an example of transitions in use on Spektrum’s site:

Using Transitions

The simplest way to achieve transition effects on your page is through Vue’s <transition> component. It makes things so simple, it almost feels like cheating. Vue will detect if any CSS animations or transitions are being used and will automatically toggle classes on the transitioned content, allowing for a perfectly timed transition system and complete control.

First step is to identify our scope. We tell Vue to prepend the transition classes with modal, for example, by setting the component’s name attribute. Then to trigger a transition all you need to do is toggle the content’s visibility using the v-if or v-show attributes. Vue will add/remove the classes accordingly.

There are two „directions” for transitions: enter (for an element going from hidden to visible) and leave (for an element going from visble to hidden). Vue then provides 3 „hooks” that represent different timeframes in the transition:

  • .modal-enter-active / .modal-leave-active: These will be present throughout the entire transition and should be used to apply your CSS transition declaration. You can also declare styles that need to be applied from beginning to end.
  • .modal-enter / .modal-leave: Use these classes to define how your element looks before it starts the transition.
  • .modal-enter-to / .modal-leave-to: You’ve probably already guessed, these determine the styles you wish to transition towards, the „complete” state.

To visualize the whole process, take a look at this chart from Vue’s documentation:

How does this translate into code? Say we simply want to fade in and out, putting the pieces together would look like this:

<button class="modal__open" @click="modal = true">Help</button>

<transition name="modal">
  <section v-if="modal" class="modal">
    <button class="modal__close" @click="modal = false">&times;</button>
  </section>
</transition>
.modal-enter-active,
.modal-leave-active { transition: opacity 350ms }

.modal-enter,
.modal-leave-to { opacity: 0 }

.modal-leave,
.modal-enter-to { opacity: 1 }

This is likely the most basic implementation you will come across. Keep in mind that this transition system can also handle content changes. For example, you could react to a change in Vue’s dynamic <component>.

<transition name="slide">
  <component :is="selectedView" :key="selectedView"/>
</transition>
.slide-enter { transform: translateX(100%) }
.slide-enter-to { transform: translateX(0) }
.slide-enter-active { position: absolute }

.slide-leave { transform: translateX(0) }
.slide-leave-to { transform: translateX(-100%) }

.slide-enter-active,
.slide-leave-active { transition: all 750ms ease-in-out }

Whenever the selectedView changes, the old component will slide out to the left and the new one will enter from the right!

Here’s a demo that uses these concepts:

See the Pen VueJS transition & transition-group demo by Nicolas Udy (@udyux) on CodePen.

Transitions on Lists

Things get interesting when we start dealing with lists. Be it some bullet points or a grid of blog posts, Vue gives you the <transition-group> component.

It is worth noting that while the <transition> component doesn’t actually render an element, <transition-group> does. The default behaviour is to use a <span> but you can override this by setting the tag attribute on the <transition-group>.

The other gotcha is that all list items need to have a unique key attribute. Vue can then keep track of each item individually and optimize its performance. In our demo, we’re looping over the list of companies, each of which has a unique ID. So we can set up our list like so:

<transition-group name="company" tag="ul" class="content__list">
  <li class="company" v-for="company in list" :key="company.id">
    <!-- ... -->
  </li>
</transition-group>

The most impressive feature of transition-group is how Vue handles changes in the list’s order so seamlessly. For this, an additional transition class is available, .company-move (much like the active classes for entering and leaving), which will be applied to list items that are moving about but will remain visible.

In the demo, I broke it down a bit more to show how to leverage different states to get a cleaner end result. Here’s a simplified and uncluttered version of the styles:

/* base */
.company {
  backface-visibility: hidden;
  z-index: 1;
}

/* moving */
.company-move {
  transition: all 600ms ease-in-out 50ms;
}

/* appearing */
.company-enter-active {
  transition: all 300ms ease-out;
}

/* disappearing */
.company-leave-active {
  transition: all 200ms ease-in;
  position: absolute;
  z-index: 0;
}

/* appear at / disappear to */
.company-enter,
.company-leave-to {
  opacity: 0;
}

Using backface-visibility: hidden on an element, even in the absence of 3D transforms, will ensure silky 60fps transitions and avoid fuzzy text rendering during transformations by tricking the browser into leveraging hardware acceleration.

In the above snippet, I’ve set the base style to z-index: 1. This assures that elements staying on page will always appear above elements that are leaving. I also apply a absolute positioning to items that are leaving to remove them from the natural flow, triggering the move transition on the rest of the items.

That’s all we need! The result is, frankly, almost magic.

Using Animations

The possibilities and approaches for animation in Vue are virtually endless, so I’ve chosen one of my favourite techniques to showcase how you could animate your data.

We’re going to use GSAP’s TweenLite library to apply easing functions to our state’s changes and let Vue’s lightning fast reactivity reflect this on the DOM. Vue is just as comfortable working with inline SVG as it is with HTML.

We’ll be creating a line graph with 5 points, evenly spaced along the X-axis, whose Y-axis will represent a percentage. You can take a look here at the result.

See the Pen SVG path animation with VueJS & TweenLite by Nicolas Udy (@udyux) on CodePen.

Let’s get started with our component’s logic.

new Vue({
  el: '#app',
  // this is the data-set that will be animated
  data() {
    return {
      points: { a: -1, b: -1, c: -1, d: -1, e: -1 }
    }
  },

  // this computed property builds an array of coordinates that
  // can be used as is in our path
  computed: {
    path() {
      return Object.keys(this.points)
        // we need to filter the array to remove any
        // properties TweenLite has added
        .filter(key => ~'abcde'.indexOf(key))
        // calculate X coordinate for 5 points evenly spread
        // then reverse the data-point, a higher % should
        // move up but Y coordinates increase downwards
        .map((key, i) => [i * 100, 100 - this.points[key]])
    }
  },

  methods: {
    // our randomly generated destination values
    // could be replaced by an array.unshift process
    setPoint(key) {
      let duration = this.random(3, 5)
      let destination = this.random(0, 100)
      this.animatePoint({ key, duration, destination })
    },
    // start the tween on this given object key and call setPoint
    // once complete to start over again, passing back the key
    animatePoint({ key, duration, destination }) {
      TweenLite.to(this.points, duration, {
        [key]: destination,
        ease: Sine.easeInOut,
        onComplete: this.setPoint,
        onCompleteParams: [key]
      })
    },
    random(min, max) {
      return ((Math.random() * (max - min)) + min).toFixed(2)
    }
  },

  // finally, trigger the whole process when ready
  mounted() {
    Object.keys(this.points).forEach(key => {
      this.setPoint(key)
    })
  }
});

Now for the template.

<main id="app" class="chart">
  <figure class="chart__content">
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="-20 -25 440 125">
      <path class="chart__path" :d="`M${path}`"
        fill="none" stroke="rgba(255, 255, 255, 0.3)"
        stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>

      <text v-for="([ x, y ]) in path" :x="x - 10" :y="y - 7.5"
        font-size="10" font-weight="200" fill="currentColor">
        {{ 100 - (y | 0) + '%' }}
      </text>
    </svg>
  </figure>
</main>

Notice how we bind our path computed property to the path element’s d attribute. We do something similar with the text nodes that output the current value for that point. When TweenLite updates the data, Vue reacts instantly and keeps the DOM in sync.

That’s really all there is to it! Of course, additional styles were applied to make things pretty, which at this point you might realize is more work then the animation itself!

Live demos (CodePen) & GitHub repo

Go ahead, browse the live demos or analyze/re-use the code in our open source repo!

Conclusion

I’ve always been a fan of animations and transitions on the web, but I’m also a stickler for performance. As a result, I’m always very cautious when it comes to relying on JavaScript. However, combining Vue’s blazing fast and low-cost reactivity with its ability to manage pure CSS transitions, you would really have to go overboard to have performance issues.

It’s impressive that such a powerful framework can offer such a simple yet manageable API. The animation demo, including the styling, was built in only 45 minutes. And if you discount the time it took to set up the mock data used in the list-transition, it’s achievable in under 2 hours. I don’t even want to imagine the migraine-inducing process of building similar setups without Vue, much less how much time it would take!

Now get out there and get creative! The use cases go far beyond what we have seen in this post: the only true limitation is your imagination. Don’t forget to check out the transitions and animations section in Vue.js’ documentation for more information and inspiration.


This post originally appeared on Snipcart’s blog. Got comments, questions? Add them below!


Creating Vue.js Transitions & Animations is a post from CSS-Tricks

Master Adobe Illustrator With These 9 Courses

Post pobrano z: Master Adobe Illustrator With These 9 Courses

If you want to master Adobe Illustrator, these nine courses will give you a solid foundation to work from. Whether you’re a beginner who wants an introduction to the essential features or a more advanced user who wants to learn new techniques, there’s something here for you.

So browse through the list, watch the quick introduction videos, and decide what you want to learn: logo design, typography, product mockups, animated icons? Or perhaps you want to master the Pen Tool or create some cool vector silhouettes. Or are you looking for a comprehensive course that takes you through the tools, panels and other features of Illustrator from start to finish? You can find all of that and more here.

1. Mastering Logo Design in Adobe Illustrator

This first course may be primarily about logo design, but it’s also a great introduction to the most important tools, panels and features of Illustrator. Instructor Daniel White takes you on a guided tour through Illustrator, showing you how everything works, before putting it all into practice by creating a complete logo design.

 

2. How to Use the Touch Type Tool in Adobe Illustrator

Let’s move from a general course to a very specific one. In this quick, ten-minute Coffee Break Course, illustrator Simona Pfreundner shows you how to use the Touch Type Tool in Adobe Illustrator CC. The Touch Type Tool can manipulate the individual characters in type as if they were separate objects. This makes this tool extremely useful as you don’t have to worry about making stylistic changes to your type that make it hard to change later on.

 

3. Creative Typography

This is really two courses in one. It will teach you how to create beautiful typography and custom lettering in Illustrator and Photoshop, but instructor Matt Withers also focuses heavily on the creative process, helping you hone your creativity as you design a piece of concept-driven, typographic artwork. If you are looking to get the most out of your creativity, and you have a keen eye for typography, this is the course for you.

 

4. Creating Product Mockups With Adobe Photoshop and Illustrator

Product mockups are a great way of helping your clients visualize how your designs will look in the real world. In this course, Grace Fussell will show you how to create your own 3D product mockups, using Adobe Illustrator to create 3D shapes and Adobe Photoshop to edit and enhance your designs. This is an immersive, easy-to-follow introduction to some of the tricks and techniques used by professional designers to create photorealistic mockups of their packaging designs.

 

5. The Fundamentals of Adobe Illustrator

If you’re looking for a solid introduction to Illustrator, or a refresher on some of its main features, this course is ideal for you. Simona Pfreundner walks you through the fundamentals of the program, so that by the end, you will be comfortable with how to use it and hopefully inspired to learn more about it.

 

6. Animating Icons With Adobe Illustrator and After Effects

Animated icons can liven up the user experience for anything from an app or website to a video game. Join concept artist Jonathan Lam to discover the step-by-step process of creating icons in Adobe Illustrator and exporting them to After Effects to animate them.

This course is perfect for designers, illustrators and game artists who are interested in animation and motion graphics.

 

7. How to Use the Pen Tool in Adobe Illustrator

The Pen Tool is without doubt one of the trickiest tools to use in Adobe Illustrator. But once mastered, it can also be the most useful tool. In this Coffee Break Course, instructor Simona Pfreundner will show you how to get to grips with using this tool, so you can become more confident and hopefully more productive in your design work.

 

8. Vector Silhouettes for Beginners

If you’re relatively new to Illustrator and haven’t mastered the Pen Tool yet, try this course to discover how you can create great end results by following some simple steps. Tuts+ Design & Illustration Editor Sharon Milne walks you through the process of creating two fun silhouette-based projects, helping you learn some great new tools and processes along the way.

 

9. Mastering Color in Adobe Illustrator

When you’re learning new design skills, it can be easy to overlook something simple and fundamental like color. Although you learned the fundamentals of colors as a child, there’s a lot more to discover. The right colors can set a mood, change a mood, and communicate all sorts of things. 

In this course, Simona Pfreundner will show you how to color your artwork in Adobe Illustrator, how to be really efficient with it, and how to use color to spark your creativity.

 

Watch Any Course Now

You can take any of our Illustrator courses straight away with a subscription to Envato Elements. For a single low monthly fee, you get access not only to these courses, but also to our growing library of over 1,000 video courses and industry-leading eBooks on Envato Tuts+. 

Plus you now get unlimited downloads from the huge Envato Elements library of 300,000+ creative assets. Create with unique fonts, photos, graphics and templates, and deliver better projects faster.