Friday, July 27, 2018

Google Flutter From Scratch: Building Apps With Widgets

AniJS: Easy CSS Animations Without Coding

Many people want to add subtle animations to their website in response to clicks or other actions by their visitors. However, not everyone is well-versed in using CSS or JavaScript. Some just know how to modify the HTML and have the change reflect on the website.

Generally, this is the part where developers take over and add the necessary JavaScript and CSS to make your website stand out. However, if you want to be able to build an animated site yourself, without coding, a library called AniJS would help a great deal.

AniJS lets you create animated styling for your website without any JavaScript or CSS coding! You can specify all your animations from HTML using a simple If-On-Do-To syntax.

Installation

Before you can begin animating the elements on your webpage using data-anijs attributes, you will have to include the necessary files. Three different files are needed to access all the functionality of AniJS. These files are the core JS library, the CSS file for the animations and another helper JavaScript file for using some special AniJS syntax like $addClass, $toggleClass, and $removeClass.

You can also install the library using Bower by running the following command:

Once you have included all the necessary files, the elements on your webpage will be animation ready.

Getting Started with AniJS Syntax

In its basic form, AniJS uses the following syntax to animate particular elements based on any event.

Here, the If part specifies the event which will trigger the animation or class manipulation. The On part specifies the element whose events AniJS should be listening to. This can be different from the element on which you have set up the data-anijs attribute. The Do part specifies the action to take. Here, you can specify the name of the animation that you want to apply etc. Finally, the To part is used to specify the element which needs to be animated or manipulated.

The If part is necessary for the AniJS statement that you add to animate any element. The On part is optional and if left unspecified uses the current element as the default value. The Do part is also necessary as it tells the browser what to do when the specified event happens. The To part is also optional and defaults to the current element when not specified.

You can also use the Before and After hooks to specify what should happen before and after AniJS does the thing mentioned inside the Do part.

Animating Different Elements

AniJS allows you to run an animation by triggering it on any applicable event listed on the MDN page. Similarly, you can use the on and to target any element you want using CSS selectors. For example, you could specify that you want to listen to an event on div.promotion or section div p.first etc. The do part can be used to specify the animation that you want to apply to different elements. AniJS has a lot of animations which can be applied on any element you want.

The following HTML snippet will show you how to apply some animations on elements which will be triggered on certain events.

In each case, all you have to do is just write the statements inside the data-anijs attribute and the library will take care of the rest. (We have skipped the to part in all these animations so the animation is applied on the element inside which we have specified the data-anijs attribute.)

The last four boxes have different values for the on part. This, for example, means that the animation on green box will happen only when the mouse moves over the brown box. Similarly, the bounce animation on the yellow box will start playing whenever a user double clicks anywhere inside the body.

You can try these animations out yourself in the embedded CodePen demo.

Manipulating Classes and HTML Elements

AniJS allows you to do more than simply animate different elements. For example, you can use it to add, remove or toggle classes applied on different elements. Similarly, you can also remove HTML elements or clone them without adding a single line of JavaScript. The library also allows you to traverse the DOM using special reserved keywords.

Let's begin with class manipulation. AniJS has three reserved keywords for manipulating classes. These are $addClass, $removeClass and $toggleClass. As, the name suggests, you can use them to add, remove and toggle one or multiple classes of an element respectively. All you have to do is specify the class names after the reserved keywords.

Similarly, you can use reserved keywords like $parent, $ancestors, $closest, $find and $children to traverse the DOM.

You can use these two sets of reserved keywords together to do something like add a certain class to all the children of an element after a visitor double clicks that particular element. However, which children you are referring to can be ambiguous in certain cases. For example, you might have applied the data-anijs attribute on one element but set the value of On part to something else using CSS selectors. In this particular situation, AniJS will have no way of knowing if the class has to be added to the children of the element referred by the CSS selector or the element on which you have applied the data-anijs attribute. In such cases, you can remove the ambiguity by using another reserved keyword called target. Here, target refers to the element pointed by the CSS selector.

Consider the following three examples in which AniJS has been used to toggle classes of different elements:

In the above example, I have reformatted the HTML to make it easier to read and see what's going on.

Let's begin with the first div. In this case, we have omitted both the on and to part of the data-anijs attribute value. Therefore, they both default to the current div itself. If you try to click on this particular div, it will toggle the orange class which in turn changes the box to orange.

In case of second div, we are telling AniJS to toggle the class called red for all elements which are children of that particular div.This will rotate all the children span elements as well as change their color to red while setting the border-radius to zero.

We have supplied two different statements inside the data-anijs attribute of the third div. Both these statements toggle the same yellow class. However, the effects are completely different due to use of the target keyword.

In the first case, we have added the target keyword after the $parent keyword. This tells AniJS that we want to toggle the class for the parent of the elements pointed by the shells class. In the second case, we have skipped the target keyword, so AniJS changes the background of the parent of current div. Since, the parent of the div is the body itself, the whole page turns yellow.

You can try clicking on different elements and see how they affect the page in the embedded CodePen demo.

One more thing worth noticing is that even though the data-anijs attribute for the third box has two statements, clicking the box itself does not have any effect. This is because we have instructed Anijs to listen to the click events on the span elements with class shells in both the cases.

Other Ways to Manipulate HTML

Another way to manipulate HTML elements on a webpage using AniJS would be to clone or remove them. The library has reserved the keywords $remove and $clone which will tell it whether you want to remove an element or clone it.

You can pass multiple selectors to $remove in order to remove multiple elements from the webpage. Keep in mind that different CSS selectors need to be separated with the pipe  | character.

The $clone keyword also accepts two parameters. The first one is the CSS selector to specify the element you want to clone. The second one is a number to specify how many copies you want to make. For instance, $clone .shells|10 will make 10 copies of the elements with class shells and append them as children of the element on which the data-anijs attribute has been specified. If the copies have to be appended to a different element, you can point AniJS to it by specifying the appropriate CSS selector after to in the AniJS statement.

Conclusion

The aim of this tutorial was to help you get started with AniJS as quickly as possible. As you might have noticed, the library is very easy to use. All you have to do is specify the right attribute values and AniJS will take care of everything else like changing classes, manimulating the DOM, and animating any changes.

The library offers a lot of other features that we have not covered in this tutorial. You should go through the official documentation to learn more about it and use it to its full potential.


by Monty Shokeen via Envato Tuts+ Code

Instagram to Work On Providing Previews For IGTV Videos

After its recent launch as an updated feature on already existing Instagram as well as a separate App, IGTV, may soon get a preview featured in the main news feed. A tweet by Matt Navarra turned our attention towards this probable update that Instagram is working on and may release soon. You will...

[ This is a content summary only. Visit our website https://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Mehwish Mehmood via Digital Information World

Ionic 4 beta, the Web Beacon API, and some golden oldies

#396 — July 27, 2018

Read on the Web

JavaScript Weekly

If you've not ventured to the end of an issue of JavaScript Weekly recently, you'll be missing some of the bonus links or 'golden oldies' we've been running — this issue has a set of 4 older posts we've been seeing getting some fresh love on social media recently, so check those out.

Also, if you want to submit articles or libraries for us to consider use this submissions form or just hit reply :-) Thanks!
— Peter Cooper, editor

Logging Activity with the Web Beacon API — The Beacon API is a Web API (supported by all major browsers) that provides an efficient way for data to be asynchronously sent from a page back to a server for logging purposes.

Drew McLellan

Ionic 4 Beta Released: Build Native Apps with Web Tech — The beta release of Ionic 4, a framework for building native apps and PWAs with Web technology, has just landed. 4.0 marks the first version to completely embrace modern Web APIs such as Custom Elements, CSS Variables and Shadow DOM, plus it’s framework-agnostic at its core.

Ionic

Developer Tools for Every Customer Session – New in FullStory — Your browser developer tools are now available for site sessions other than your own. Easily understand performance issues thanks to page speed metrics, network analysis, downloadable HAR files, and comprehensive stack traces on all your visitors’ sessions.

Fullstory sponsor

JavaScript Algorithms and Data Structures — JavaScript examples of many common algorithms (e.g. bit manipulation, Pascal’s triangle, Hamming distance) and data structures (e.g. linked lists, tries, graphs) with explanations. (We linked this a couple of months ago but it has been substantially improved since then.)

Oleksii Trekhleb

ndb: An Improved Debugging Experience for Node — Run your Node code with ndb and get extra, powerful Node debugging features right in Chrome’s DevTools including editing files and setting breakpoints before modules are loaded.

Google Chrome Labs

Build a State Management System with Vanilla JavaScript — Redux, MobX and Vuex can make managing cross-component state trivial, but what would it take to write one for yourself?

Andy Bell

GitHub Finishes Removing jQuery From Its Web Frontend — And they’ve replaced it with.. no specific framework, but judicious use of querySelectorAll, custom elements, polyfills, etc.

Mislav Marohnić on Twitter

SimpleDataTable: A Simple Data Table Control with No DependenciesExamples. Significantly lighter than the TUI Grid we linked last week.

Piotr Kowalski

💻 Jobs

Lead Engineer (Boston) — Work with smart devs and designers to solve meaningful problems for great clients. React, Vue, Gatsby, WordPress, Craft, and more.

Upstatement

Find A JavaScript Job Through Vettery — Vettery specializes in developer roles and is completely free for job seekers.

Vettery

📘 Tutorials and Opinions

Redux vs. the React Context API — How the new context API in React 16.3 works compared to Redux and why you’d choose one over the other. More like this in today’s React Status newsletter.

Dave Ceddia

Adding Particle Effects to DOM Elements with Canvas — A neat tutorial showing how to create a striking HTML-to-particle effect.

Zach Saucier

A Crash Course on Serverless APIs with Express and MongoDB — A really detailed look at running Express (the Node.js webapp library) in a serverless context.

Adnan Rahić

Want to Know More About Ubuntu 18:04? DigitalOcean Can Help — DigitalOcean offers tutorials, projects and answers to your questions about Ubuntu 18:04.

DigitalOcean sponsor

Hello Vue: A Quick Tutorial on Getting Started with Vue — A quick tutorial on getting started with Vue that includes the use of a component from the Kendo UI library of Vue UI components.

John Willoughby

Building 'Renderless' Vue Components

Samuel Oloruntoba

Crafting a Better User Experience During API Requests

Ryan Baker

Why the New V8 is So Darn Fast

Thorsten Lorenz

Free Video Course: How to Upgrade Cordova Applications to Native

NativeScript sponsor

A Comprehensive Guide to Working with Dates in JavaScript

Flavio Copes

Flow Control in Modern JS: From Callbacks to Promises to Async/Await — One for beginners/learners.

Craig Buckler

🔧 Code and Tools

Vuestic Admin: A Vue.js Admin Dashboard — Built on Bootstrap 4. Live demo.

Epicmax

StealJS 2.0: The 'Futuristic' Dependency Loader and Builder

Matthew Phillips

JSInspect: Detect Copy-Pasted and Structurally Similar Code — A tool for finding those duplicated code smells in your codebase. Supports ES6, JSX and Flow.

Daniel St. Jules

Application Stability Monitoring with Bugsnag — Make data-driven decisions on whether you should be building features, or fixing bugs to stabilize your app.

Bugsnag sponsor

jsQR: A Pure QR Code Reading LibraryLive demo. It’s incredibly fast.

Cosmo Wolfe

Angular 6.1 Released — A minor release that’s a drop-in replacement for Angular 6.0. TypeScript 2.8 and 2.9 support has been added.

Stephen Fluin (Google)

excel4node: An Excel Spreadsheet (XLSX) Generation Library — Conforms to the ECMA-376 OOXML specification 2nd edition and the examples in the documentation are quite thorough.

Nathan (Nater) Jorde

Unswitch: An Event Handler for Nintendo Switch Controllers on the Web — Based on the Gamepad API.

Colin van Eenige

☀️ Some Summery JavaScript Golden Oldies

JavaScript Scope and Closures: A Useful Primer/Explainer — A true golden oldie if you want to nail down your knowledge of scope and closures.

Zell Liew

Debugging Tips and Tricks for Front-End Developers — A fantastic round-up of concepts, tools, and things to consider.

Sarah Drasner

Modern JavaScript for Ancient Web Developers“Doing is learning. Doing it badly? It’s still learning. Learning modern JavaScript these days can feel like a futile exercise in WTF.”

Gina Trapani

Babel Time Travel: See Babel Transformations Step by Step — Click “Compile” on the right then skim along the bottom.

Boopathi Rajaa


by via JavaScript Weekly

Mariano Pascual

Brilliantly unique One Pager filled with personality for Argentinian designer, Mariano Pascual. The website mimics an interactive desktop on a vintage Operating System featuring a taskbar, menubar and draggable windows. One of the most unique and inspiring websites you’ll see this year.

Full Review | Direct Link


by Rob Hope @robhope via One Page Love

Facebook Reveals Some Information About Its Content Moderators

Ever wondered what happens to a post once it is marked for review? What does Facebook do with the content which is deemed inappropriate? The platform explained a little about the reviewing process and the force behind it. A team of 7500 people manages the posts which are marked as potentially...

[ This is a content summary only. Visit our website https://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Neha Zaidi via Digital Information World

Spyware Campaign's Malicious Deeds Affect Over 11 Million Android, iOS and Web Users by Stealing Private Information

It seems as though the efforts made by Google and Mozilla, to safeguard their extensions is failing miserably, and they are unable to prevent private information from leaking to third parties. Only recently, it was found that extensions of the said browsers were busy extracting and collecting...

[ This is a content summary only. Visit our website https://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Neha Zaidi via Digital Information World