essetwide / material-walkthrough

A material tour (eg Inbox from Google).
https://essetwide.github.io/material-walkthrough/
Apache License 2.0
32 stars 10 forks source link

outerWidth and outerHeight #33

Closed oliveirafilipe closed 6 years ago

oliveirafilipe commented 7 years ago

Atualmente nas linhas 287 e 288 utiliza-se outerWidth e outerHeight, entretanto estes são funções de jQuery.

Baseado no site http://youmightnotneedjquery.com/ temos as seguintes soluções:

function outerHeight(el) {
  var height = el.offsetHeight;
  var style = getComputedStyle(el);

  height += parseInt(style.marginTop) + parseInt(style.marginBottom);
  return height;
}

outerHeight(el);
function outerWidth(el) {
  var width = el.offsetWidth;
  var style = getComputedStyle(el);

  width += parseInt(style.marginLeft) + parseInt(style.marginRight);
  return width;
}

outerWidth(el);
menosprezzi commented 7 years ago

acho que vamos trabalhar com o clientRect que é mais estável e é baseado no que está visível. https://developer.mozilla.org/pt-BR/docs/Web/API/Element/getClientRects