Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

122
Views
is it possible to prevent grid item from being created beyond a fix canvas?

I am following this guide in creating adding and removing grid item. However, is it possible to prevent it from creating beyond a fix canvas size?

for example, my canvas height is 300px, so when i click the add item button, no element will be created.

This is my current function that check for the desired height

warningMessage = () => {
    var chart = document.getElementsByClassName("graph");
    var largestYvalue = "";

    for (var i = 0; i < chart.length - 1; i++) {
      var firstElement = parseInt(
        chart[i].style.transform.replace(/[\(\)]/g, "").split(",")[1]
      );
      var EachElement = parseInt(
        chart[i + 1].style.transform.replace(/[\(\)]/g, "").split(",")[1]
      );

      if (EachElement > firstElement) {
        largestYvalue = EachElement;
      }
    }

    if (largestYvalue >= 300) {
      alert("it is going beyond the canvas");
    }
  };

The canvas is define in my styles.css

.DetailLocationContainer {
  background-color: red;
  width: 100px;
  height: 300px;
  /* margin: 2% auto auto auto; */
  background-image: repeating-linear-gradient(#ccc 0 1px, transparent 1px 100%),
    repeating-linear-gradient(90deg, #ccc 0 1px, transparent 1px 100%);
  background-size: 50px 50px;
}

Grid item will be created after the alert, but what I trying to do it, to have the alert without creating the grid item

This is my codesandbox

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

if I understood you correctly one of the ways that comes straight to my mind right now is in JS

if(window.innerHeight < the_desired_height)

pretty sure not the most efficient one but it work , it can be fixed height or dynamic.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!