How to create the mechanics and appearance of the zoom effect used in the Reveal.js framework?

Asked

Viewed 103 times

1

Example: Zoom of the Reveal
Goal: Study the mechanics and appearance of Zoom with the best algorithmic solutions.

- Of the problem of appearance:
1 - When inspecting the tag < Section > looking for the background black color pattern
(background detail >> lightly white circles in the center) it presents a different color in the inspection (pink(background: #ff5e99;)) than shown in the slide.

- Of the problem of mechanics:
1 - Make the central text receive a zoom effect that exceeds the screen limits.
2 - The text becomes opaque as it moves away from the center of the screen.

Update 1

div {
  width: 100px;
  height: 100px;
  border: 1px solid black;
  margin-left: 200px;
  margin-top: 50px;
  -webkit-animation-name: zoom;
  -webkit-animation-duration: 350ms;
  -webkit-transform: translate(150%, 150%);
  -webkit-transform: scale(1.1, 1);
  -webkit-transition: translate 2s;
  animation-name: zoom;
  animation-duration: 550ms;
  transform: translate(150%, 150%);
  transform: scale(1.1, 1);
  transition: translate 2s;
  -ms-transform: scale(1.1, 1);
}

@keyframes zoom {
  from {
    opacity: 1;
    -webkit-transform: scale3d(0.7, 0.7, 0.7);
    transform: scale3d(1, 1, 1);
  }
  10% {
    opacity: 0.5;
  }
  100% {
    opacity: 0;
    margin-left: 200px;
    margin-top: 50px;
    visibility: hidden;
  }
}

.zoom {
  -webkit-animation-name: zoom;
  animation-name: zoom;
}
<div>Test</div>

  • Much of this you solve with CSS mainly using Transform Scale() Translate(), opacity, @keyframes and medias in % or vw vh... If it’s a small project to do with practically only CSS and almost nothing from JS or jQuery to arrive at a very close result... But if the plugin already does everything pq not use it? Is it worth reinventing the wheel in your project?

  • Hello @hugocsl Thanks for responding, it is rather a small project without the need for the entire Reveal.js framework, I did an update, can help me adjust the zoom properties and black background with white circles?

  • I will try to make a basic model, but it will be basic ok as if it was only the first transition only, then you can adapt or do the rest of the transitions etc. As soon as I have a viable example I reply to you

1 answer

1


As I told you this is a very basic example, I did a bit of a rush, but I think it will open your head to see that only with CSS you get something very close to this. Calmly and a few more lines of code you manage to adapt in your project. Logically it would only be feasible for something small, a few pages. But it’s a start for you to test the possibilities.

The techniques used are basically, scale(), blur(), opacity, and a checkbox to pass the slide, but depending on a radio buttom be better. Here is an example of slide only with CSS that I did in other reply tb only with CSS: Vertical scroll by sections (like a slide)

See how the result turned out:

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}
input {
    display: none;
}
.slide {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    background-image: radial-gradient(circle, #999, #000);
    background-repeat: no-repeat;
    background-size: cover;
}
.slide label {
    border-top: 50px solid rgba(255,255,255,0.5);
    border-bottom: 50px solid transparent;
    border-left: 50px solid transparent;
    border-right: 50px solid transparent;
    position: absolute;
    bottom: 0px;
    right: 20px;
    cursor: pointer;
}
.slide label:hover {
    border-top: 50px solid #fff;
}
.efeito {
    font-family: sans-serif;
    font-size: 8vw;
    color: #fff;
    opacity: 1;
    filter: none;
}
@keyframes testex {
    0% {
        transform: scale(1);
        opacity: 1;
        filter: none;
    }
    99% {
        transform: scale(20);
        opacity: 0;
        filter: blur(5px);
    }
    100% {
        transform: scale(20);
        opacity: 0;
        filter: blur(5px);
        display: none;
        z-index: -999;
    }
}
#bn1:checked ~ #sn1 {
    animation: testex 1s forwards;
}

#sn2 {
    opacity: 0;
    transition: all 1s;
}

#bn1:checked ~ #sn2 {
    opacity: 1;
}
<input type="checkbox" name="" id="bn1">

<section class="slide" id="sn1">
    <label for="bn1"></label>
    <div class="efeito">
        <span>1 texto 123</span>
    </div>
</section>

<section class="slide" id="sn2">
    <label for="bn1"></label>
    <div class="efeito">
        <span>2 texto 456</span>
    </div>
</section>

  • It was really good @hugocsl, thanks man!

  • @user31050 the structure here of HTML is not the best, the code of the other answer I quoted I think would be better for a starting point. Just take the effect I put in this answer and adapt on the slide of the other, because I thought it was better done :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.