carnationpoints
v1.0.6
Published
Responsive Breakpoints
Maintainers
Readme
# NPM
npm i carnationpointsconst points = carnationPoints(".myBox");const points = carnationPoints(".myBox", {
breakpoints: [
{ name: "mobile", max: 767 },
{ name: "tablet", min: 768, max: 1023 },
{ name: "desktop", min: 1024 },
],
});const points = carnationPoints(".myBox", {
breakpoints: [
{ name: "mobile", max: 767 },
{ name: "tablet", min: 768, max: 1023 },
{ name: "desktop", min: 1024 },
],
onInit(point) {
console.log("Init:", point.breakpoint);
},
});const points = carnationPoints(".myBox", {
breakpoints: [
{ name: "mobile", max: 767 },
{ name: "tablet", min: 768, max: 1023 },
{ name: "desktop", min: 1024 },
],
onChange(point) {
console.log("Resize:", point.breakpoint);
},
});const points = carnationPoints(".myBox", {
breakpoints: [
{ name: "mobile", max: 767 },
{ name: "tablet", min: 768, max: 1023 },
{ name: "desktop", min: 1024 },
],
});
points.addPoint([
{ name: "lg", min: 1200 },
{ name: "xl", min: 1600 },
]);const points = carnationPoints(".myBox", {
breakpoints: [
{ name: "mobile", max: 767 },
{ name: "tablet", min: 768, max: 1023 },
{ name: "desktop", min: 1024 },
],
});
points.destroy();points.el.addEventListener("breakpoint:change", function (e) {
if (e.detail.breakpoint === "mobile") {
console.log("Mobile active");
}
});<html>
<head>
<script src="./dist/carnationpoints.min.js"></script>
</head>
<body>
<div class="your-element-name">
Box
</div>
<script>
const points = carnationPoints(".your-element-name", {
breakpoints: [
{ name: "mobile", max: 767 },
{ name: "tablet", min: 768, max: 1023 },
{ name: "desktop", min: 1024 },
],
});
</script>
</body>
</html>