Thursday, June 2, 2016

Level Up: Building a Brand-New Browser

[author_more]

This article is part of a web development series from Microsoft. Thank you for supporting the partners who make SitePoint possible.

We designed Microsoft Edge to work the way you do, with cool features that let you do more right in the browser. In this talk, we'll walk through how we're learning from feedback to build a vision for the future of the browser, from top-requested power-user features to major investments in new ways to look at the web.

This article is part of the web development series from Microsoft tech evangelists and engineers on practical JavaScript learning, open source projects, and interoperability best practices including Microsoft Edge browser and the new Edge HTML rendering engine.

We encourage you to test across browsers and devices including Microsoft Edge – the default browser for Windows 10 – with free tools on dev.microsoftedge.com, including F12 developer tools — seven distinct, fully-documented tools to help you debug, test, and speed up your webpages. Also,  visit the Edge blog to stay updated and informed from Microsoft developers and experts.

Continue reading %Level Up: Building a Brand-New Browser%


by Microsoft Developers via SitePoint

Introducing the CSS clip-path Property

The web is predominantly rectangular. On the other hand, print media tends to be more varied in shape. Among the many reasons for this difference is a lack of appropriate tools to achieve what we have in print media.

This tutorial will introduce you to clip-path, a property which allows you to prevent a portion of an element from being displayed. The region that is visible is governed by the values you provide. We will begin with the basics, then cover the syntax and later on move to more advanced concepts.

The Basics

Clipping is when we trim a piece from something. In our case, it is an operation which allows us to completely or partially hide elements on a web page. Two other concepts that relate to clipping which we will use in this article are clipping path and clipping region.

Clipping path is the path we use to clip an element, it marks out our clipping region. It can be a basic shape or a complex polygonal path. The clipping region then includes all the area enclosed within the clipping path.

Anything outside the clipping region is clipped by the browsers. This not only includes backgrounds and other such content but also borders, text-shadows and so on. Moreover, browsers won't capture any events like hover or click outside an element's clipping region.

Even though our specific element is now non-rectangular, the content around the elements flows exactly the way it would have if the element had its original shape. To make the surrounding elements flow according to the shape of the clipped element, you will have to use the shape-outside property. This has been covered in detail in this SitePoint tutorial.

Also, keep in mind that you do not want to confuse this property with the deprecated clip property which was very restrictive and only supported rectangular clipping.

Syntax and Usage

The correct syntax for using this property is:

clip-path: <clip-source> | [ <basic-shape> || <geometry-box> ] | none

The syntax values above include:

  • clip-source will be a URL referencing an internal or external SVG <clipPath> element.
  • basic-shape accepts the basic shape function defined in the CSS Shapes specification.
  • geometry-box is optional. When you provide it along with the basic-shape function, it acts like a reference box for the clipping done by basic-shape. If geometry-box is specified by itself, then it uses the shape of specified box, including any corner shaping (provided by the border-radius property) as the clipping path. We will explore this further soon.

Now, consider the following CSS code which uses the basic shape function:

img {
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

It will clip all the images in the shape of a rhombus. But why are the images being clipped in shape of a rhombus and not a trapezium or parallelogram? It all depends on the value of your vertices. The following diagram illustrates the conventions to be used when you are creating your own polygon shapes for clipping:

Clipping Polygon diagram

The first coordinate of each point determines its location on the x-axis. Similarly, the second point specifies its location on the y-axis. The points are all plotted in a clockwise direction. Consider the rightmost point of our rhombus. It is located half way down the y-axis, so its y coordinate is 50%. It is also located at the extreme right position on the x-axis, so its x coordinate is 100%. Values of all other points can be deduced similarly.

Clipping Elements With geometry-box Values

When you are clipping a HTML element the geometry-box (or reference box) can be any one of the following — margin-box, border-box, padding-box or content-box. The geometry-box value should be used in following manner:

[code language="css"]
.clip-me {
clip-path: polygon(10% 20%, 20% 30%, 50% 80%) margin-box;
margin: 10%;
}
[/code]

In the case above, the margin-box of our element will be used as a reference to determine the exact location of clipping points. The point (10%, 10%) is the top-left corner of our margin-box and thus our clip-path would be positioned in relation to that point.

In case of SVG elements, it can be fill-box, stroke-box and view-box. The value view-box will use the nearest SVG viewport as a reference box if no view-box is specified.

Uses of clip-path

This property has a lot of interesting uses. Firstly, it can improve our text content. Take a look at the image below. The background behind the headline and the second paragraph was created using clip-path property:

clip-path examples

Continue reading %Introducing the CSS clip-path Property%


by Nitish Kumar via SitePoint

This week's JavaScript news, issue 286

This week's JavaScript news
Read this e-mail on the Web
JavaScript Weekly
Issue 286 — June 2, 2016
Eric Elliott compares 3 approaches to prototypal inheritance: differential, concatenative, and functional.
Eric Elliott

A look at advances in V8, ES6, and WebAssembly, plus a demonstration of debugging Node via Chrome’s DevTools.
Seth Thompson

A look at avoiding ‘callback hell’ in JavaScript by using new features in ES6 and ES7, plus some lessons learnt using them in production.
Guillermo Rauch

Learn how to build functional, reactive web applications in Angular 2 with a Redux inspired library, @ngrx/store and observables from Rx.js.
Frontend Masters   Sponsored
Frontend Masters

Includes localization, theming, and keyboard support, and looks good on both desktop and mobile.
Claudéric Demers

Tim Severien provides a variety of tips for when building your own library, ranging from API design to testing and documentation.
Tim Severien

If you enjoy a good code dig, this is for you. A developer digs into Facebook’s JavaScript code to detect when his friends are typing.
Alex Kirszenberg

30 different techniques or syntax elements from React, Angular 1 and 2, Polymer, Vue and Ember are compared in this table.
Jeff Carpenter

Jobs

In brief

Curated by Peter Cooper and published by Cooper Press.

Stop getting JavaScript Weekly : Change email address : Read this issue on the Web

© Cooper Press Ltd. Office 30, Lincoln Way, Louth, LN11 0LS, UK


by via JavaScript Weekly

Fretl

Delivery of fruits and vegetables fresh at home.


by csreladm via CSSREEL | CSS Website Awards | World best websites | website design awards | CSS Gallery

Field Notes

Field Notes have been adored by fans the world over since the first notebooks were introduced a decade ago by the fine folks at Draplin Design Co. and Coudal Partners. We’ve made the online Field Notes experience easier and more fulfilling for every


by csreladm via CSSREEL | CSS Website Awards | World best websites | website design awards | CSS Gallery

Andra Popovici Illustrations

Portfolio of Andra Popovici, illustrator and designer based in Bucharest, Romania.


by csreladm via CSSREEL | CSS Website Awards | World best websites | website design awards | CSS Gallery

Gianluca Vedovato

Gianluca Vedovato’s portfolio website. Collection of works and projects by Gianluca Vedovato, 23y old web designer based in Venice


by csreladm via CSSREEL | CSS Website Awards | World best websites | website design awards | CSS Gallery