Use FocusPoint. js to achieve responsive image cropping and focuspoint. js Cropping

Source: Internet
Author: User

Use FocusPoint. js to achieve responsive image cropping and focuspoint. js Cropping

Generally, the website layout is not single. For example, the shape displayed on a computer, tablet, or smartphone may be different. Especially if you are using a full-screen image, when you must use the same image file, your subject may be truncated or completely missing, or it may look embarrassing.

FocusPointJQueryThe plugin ensures that any container in your image looks great. It introduces the "response cropping" concept and ensures that important components of your image are cropped, dynamic image cropping is used to fill the available space without cropping the topic of the image.

 

 

Download demo source code

 

Usage: 1. Calculate the focal point of an image.

The focal point of an image is composed of X (horizontal) and Y (vertical) coordinates. The coordinate value can be any number in the range of-1 to + 1, with 0 as the center. X:-1 indicates the left border of the image. x: 1 indicates the right border of the image. For the y axis, y: 1 indicates the upper boundary of the image, and y: 1 indicates the lower boundary of the image.

<Link rel = "stylesheet" href = "focuspoint.css"> <script src = "jquery. js "> </script> <script src =" focuspoint. js "> </script>3. Mark the image container

Coordinates of the specified image size and image container focal point. Note: I know this does not really need to specify the image size, but I found this is more reliable than reading the size from the image. For example:

<div class="focuspoint"data-focus-x="0.331"data-focus-y="-0.224"data-image-w="400"data-image-h="300">    </div>
4. Call the FocusPoint plug-in

For basic calls, only one line of code is required:

$('.focuspoint').focusPoint();

Currently, there are not many available configuration options, but if you want to prevent the image from being re-focused when the window size changes, you can:

$('.focuspoint').focusPoint({    reCalcOnWindowResize : false});

At any time, you can call adjustFocus to re-focus the image:

$('.focuspoint').adjustFocus()

 

Demo GitHub Homepage

 

Articles you may be interested in
  • 10 useful results in Web development [Source Code download]
  • Excellent jQuery Ajax paging plug-ins and tutorials carefully selected
  • 12 amazing creative 404 error page Designs
  • Let the website get started! 12 excellent jQuery animation plug-ins
  • Amazing 8 HTML5 & JavaScript Special Effects

 

Link to this article: FocusPoint. js-jQuery plug-in for responsive image Cropping

Source: Dream sky ◆ focus on front-end development technology ◆ share web design resources

Source of this article [http://www.cnblogs.com/lhb25 /]




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.