You could do it like this:
const dragInteraction = new Translate();
dragInteraction.on('translating', (event) => {
const features = event.features.getArray();
const featureExtents = features.map(x => x.getGeometry()?.getExtent());
let boundingFeatureExtent = createEmpty();
for (const extent of featureExtents) {
if (!extent) {
continue;
}
extend(boundingFeatureExtent, extent)
}
const mapView = map.getView();
const viewExtent = mapView.calculateExtent();
if (!containsExtent(viewExtent, boundingFeatureExtent)) {
mapView.fit(extend(viewExtent, boundingFeatureExtent));
}
})
https://jsfiddle.net/komarara/zheuncb3/29/